With fedora 15 or 16, I don't find the directory for execute a shell script automaticaly at shutdown...

1 Answer 1


Fedora 16 has replaced the legacy "System V" style init scripts -- which let you run scripts at startup and shutdown via scripts in /etc/rc.d -- with systemd. You can create a systemd service file that runs a shell script when it starts and stops, much like a traditional init script. Put something like the following in /lib/systemd/system/runonshutdown.service:

ExecStart=/path/to/myscript start
ExecStop=/path/to/myscript stop


With this in place, you can then run:

# chkconfig runonshutdown on
ln -s '/lib/systemd/system/runonshutdown.service' '/etc/systemd/system/multi-user.target.wants/runonshutdown.service'

When your system boots, it will run /path/to/myscript start, and when your system shuts down, it will run /path/to/myscript stop.

For more information, read the systemd.service(5) man page.

  • 1
    I'm glad it helped out. If this answer did solve your problem, it would be great if you could mark it as "accepted" by clicking the checkbox to the left of the answer. Thanks!
    – larsks
    Feb 22, 2012 at 20:49

You must log in to answer this question.

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