#Edit the example changing the service name and the script rute and file >$ nano [filename] ----------------------------------------------------------------------- #!/bin/sh # /etc/init.d/[service] #Only for debug #exec > /var/log/[service].log ### BEGIN INIT INFO # Provides: [service] # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: [description service] # Description: Script service for start / stop the [service]. ### END INIT INFO # If you want a command to always run, put it here # Carry out specific functions when asked to by the system case "$1" in start) log_daemon_msg "Starting [service]" echo "starting script 1" /etc/somescript.sh & echo $!>/var/run/[service].pid status=$? echo $? log_end_msg $status ;; stop) kill "cat /var/run/[service].pid" log_daemon_msg "Stopping [service]" echo "stoping script 1" log_end_msg $? echo $? ;; restart) echo "Restarting" $0 stop $0 start ;; status) status_of_proc $DAEMON "status [Service]" ;; *) echo "Usage: $0 {start|stop|restart|status}" exit 2 ;; esac exit 0 --------------------------------------------------------------------------- #Copy the file to /etc/init.d and allow execute >$ cp [filename] /etc/init.d/[filename] >$ chmod 755 [filename] #Activate the deamon for auto start (filename = %demon%) >$ sudo update-rc.d %demon% defaults #control the deamon for manual order >$ sudo service %demon% (stop / start / restart) #show status >$ sudo service %demon% status #Remove deamon from autostart >$ sudo update-rc.d -f %demon% remove"