Creating an init.d script in Debian

From HostThyself

Jump to: navigation, search

Make a copy of the skeleton script provided

cd /etc/init.d
cp skeleton myscript
chmod a+x myscript

Edit myscript to fit your need.

Some points to note:

start-stop-daemon is the main script that does all the work, see

man start-stop-daemon 

To start a script and put in the background and create a PID file use

-b -m 
or
--background --make-pidfile

Add the script to the start process. This will create appropriate System V style init script symbolic links to the rc folders

update-rc.d myscript default

Remove the script from the startup process. This will just delete the links and leave the actual file

update-rc.d -f myscript remove 

For more info, see

man update-rc.d 

The default should work for most case unless you know which runlevel you want to run.

Personal tools