Old fashioned way to create Linux daemon script and make it auto run.
Open editor
$ sudo nano myservice
and create the following script in home folder:
#! /bin/bash
#
#
start() {
echo “Starting <Service>”
}
echo “Starting <Service>”
}
stop() {
echo “Stopping <Service>”
}
echo “Stopping <Service>”
}
restart() {
stop
start
}
stop
start
}
case “$1” in
start)
start
;;
start
;;
stop)
stop
;;
stop
;;
restart)
restart
;;
restart
;;
*)
echo $“Usage: $0 {start|stop|restart}”
exit 1
echo $“Usage: $0 {start|stop|restart}”
exit 1
esac
exit 0
exit 0
Give it executable permissions:
$ sudo chmod +x myservice
Test the script:
$ ./myservice start
$ ./myservice stop
$ ./myservice restart
After the script is tested, copy it to /etc/init.d folder
$ sudo copy myservice /etc/init.d/myservice
And configure auto start with system
$ sudo update-rc.d myservice defaults
$ sudo update-rc.d myservice enable
When the service is not needed anymore, remove it
$ sudo update-rc.d -f myservice remove