2

I would like to execute two scripts, one is during start up and another one is during shutdown. I know we can add script in /etc/rc.local which will be executed on start up, but if I want to execute something on shutdown, how can I do that?

closed as off-topic by RPiAwesomeness, lenik, Jivings Apr 29 '14 at 20:01

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be specific to the Raspberry Pi within the scope defined in the help center." – RPiAwesomeness, lenik, Jivings
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    Jeez. How about, since it's ON the raspberry pi stack exchange we ASSUME it's for the raspberry pi and permit the question to be answered, that being the entire point of this website? It's a darned good question and should not have been closed. – jpwynn Jan 31 '16 at 21:10
3

Take a look at runlevels. With runlevel 0, you can execute scripts on shutdown. So you need to create your script somewhere, then create a symbolic link to it in /etc/rc0.d. And be careful about permissions.

P.S : If you want to execute some scripts on reboot, it's runlevel 6.

0

I think what you are looking for can be found here: How to execute a shell script right b4 shuting down?

  • 1
    Thank you for your contribution. Please note however that link-only answers are discouraged as the website you're linking to might possibly vanish at some point in the future. To prevent the information from becoming unavailable, please summarize the essential parts and and provide the link as a source reference. – n.st Apr 29 '14 at 18:04

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