Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

share|improve this question

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:

[Service]
Type=forking
ExecStart=/path/to/myscript start
ExecStop=/path/to/myscript stop
TimeoutSec=0
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

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.

share|improve this answer
    
Thank you, i use it on 2 fedora 16 –  Pierre Feb 22 '12 at 17:55
    
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 '12 at 20:49

Your Answer

 
discard

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.