Take the 2-minute tour ×

In reference to the following documentation, how can i read the start and stop argument? I want to tell if the computer is booting up or shutting down so that i can run the correct script.

To make the script run with the start argument at the end of the start sequence, and run with the stop argument at the beginning of the shutdown sequence:

sudo update-rc.d myscript defaults 98 02

i want to do something like this:

if [ startargument "start" ]          
share|improve this question

1 Answer 1

up vote 3 down vote accepted
case "$1" in
        echo "Starting"
        echo "Stopping $DESC"

        echo "Restarting $DESC"
        exit 1
  • "$1" adresses the 1st parameter fed to the script. So you would do your_script start or your_script stop etc.
  • Change the echo into the actual action that needs to be executed (or put it underneath it).

The document you are referencing to is old. Very old.

These links will help you with Upstart:

Upstart getting started

Upstart stanzas

Example #1 'django' server

Example #2

share|improve this answer
(+1) thanks, Does the system automatically send the "start" parameter when it starts the computer? –  capdragon Jun 20 '11 at 19:10
No! you need to feed it a 'start' yourself or optionally you could alter the script: you could add in an option that checks for some condition (like set a boolean 'booting=true') and test that and make that do the start for you. –  Rinzwind Jun 20 '11 at 19:15
(+1) The script needs to know automatically from the system... see the quote i placed? It is supposed to be passed in by the system by using (defaults 98 02) but it does not seem to start up on boot. –  capdragon Jun 20 '11 at 19:33
Forget the document you linked: it's old and outdated. This one is better upstart.ubuntu.com/getting-started.html (but also a bit more difficult to follow). Upstart is used in Ubuntu and files can include things like start on startup and start on stopped rcS to make them run when starting and stopping. –  Rinzwind Jun 20 '11 at 19:44

Your Answer


