I've got a few commands that I run in rc.local so they are run last in the startup sequence. I would like to know if there is a similar facility for undoing the results of those commands at shutdown, like an rc.shutdown. Ideally, it would be run before any of the other /etc/init.d scripts.

  • 3
    This is highly distribution-dependent. Please add information about your distribution. Aug 14, 2011 at 0:02

5 Answers 5


Not really (at least, to my knowledge).

If you've got SystemV style init scripts, you could create something along the lines of /etc/rc6.K00scriptname and /etc/rc0.d/K00scriptname, which should get executed prior to any of the other scripts in there.


ArchLinux does have a /etc/rc.local.shutdown file for this. I'm not sure about other distros


It is generally possible, but depends on the init-scripts system you have. If your distribution used a recent version of OpenRC (as Gentoo does), you could put any scripts in /etc/local.d/, call them <something>.stop and they would be run at system shutdown. For older versions, you'd have to put your commands inside local_stop() function in /etc/conf.d/local.

The order depends on the rc-system settings, but typically the local scripts are the last to run at startup and first to run at shutdown.


If you have upstart, you can catch the shutdown event and run a script when it is caught.


In Gentoo the "local" script does exactly what you ask for: It runs certain user specified commands upon 'start' and another set of commands upon 'stop'.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .