I would like to run a script file when the system is called for shutdown/ reboot from 'reboot' and 'shutdown' commands. And if possible, also hard shutdowns like 'init 0' or 'poweroff'. How would I go about doing that? A config file or command would be nice. I use systemd instead of initscripts.


Just copy / link the script into your /etc/init.d/rc0.d (HALT) and /etc/init.d/rc6.d (reboot) directories, and make sure it's name is prefixed with: "K20"

FYI: http://www.linux.com/news/enterprise/systems-management/8116-an-introduction-to-services-runlevels-and-rcd-scripts


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.