I just want to run (as root) a command or script before each reboot/shutdown/poweroff on Ubuntu 21.04 (when I run the shutdown or poweroff commands, or using GNOME/KDE GUI options). I've tried putting the script inside /etc/init.d
and making symlinks to /etc/rc6.d/
and /etc/rc0.d/
but doesn't work.
Wonder if there's such a line for sudo crontab -e
.