Adding init scripts on Debian GNU/Linux

Installing init scripts on Debian.

In this case we will install myscript.

First cd /etc/init.d then type touch myscript.

Then chmod 0755 myscript.

This creates an empty file, you can then edit that file and add your commands.

Now lets install the script with:

update-rc.d myscript defaults or if you need more control:

update-rc.d myscript start 99 2 3 4 5 . (note the . on the end).

This puts a symbolic link from myscript to the run levels 2, 3, 4 & 5 so it runs everytime one of the 4 run levels is entered. 99 means that this will be one of the last rules started (01 would be one of the first).