Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 1 down vote accepted

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"


share|improve this answer
I use systemd instead of initscripts. Know a different way to do that without using initscripts? Sorry that wasnt in my post – Wolfizen Jan 18 '13 at 16:42
The How Do I Convert A SysV Init Script Into A systemd Service File? page explains the basics, just add the appropriate WantedBy= targets to your service file e.g. [Install] / / – arober11 Jan 19 '13 at 7:18
For examples see: archlinux - systemd/Services – arober11 Jan 19 '13 at 7:25
Thanks! That guide helped alot! – Wolfizen Jan 19 '13 at 16:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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