startup and shutdown script

Asked by Jon Charge

Where do I put a script that I need to run on start and shutdown?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Jon Charge
Solved:
Last query:
Last reply:
Revision history for this message
Antonio Litterio (antonio-litterio-gmail) said :
#1

Hi Jon
if you need to launch some script during startup or shutdown you need to add script into folder /etc/init.d
and then you need to add soft link (with command 'ln -s' ) in folder related with automatic script. Those are /etc/rcX.d where the 'X' is a number between 0-6. And their meanings depending on os. For example in Debian and like Debian you'll have:
rc0.d --> Halt ( Shutdown )
rc1.d --> Single-user mode
rc2.d --> Multi-user mode without networking
rc3.d -->
rc4.d --> Full Multi-user mode
rc5.d --> Multi-user mode with GUI startup
rc6.d --> Reboot

I think that /etc/init.d/README can helps you so well then me.

Antonio

Revision history for this message
Jon Charge (seropith) said :
#2

Ok, I think I'm following... basically the script is going to save the state of the random pool on shutdown, and another one will read it back in on startu, so I think I see the ones I add for shutdown, that would be 0 and 6, however, unsure for startup.

Revision history for this message
Antonio Litterio (antonio-litterio-gmail) said :
#3

For startup depend, but I think that for you can add it in rc1.d ( this for example is called when you start os in recovery mode )
Or if you have an graphics interface after startup you could add it at rc5.d (This for example isn't called when the os start in recovery mode).

Revision history for this message
Jon Charge (seropith) said :
#4

Thank you for the help.