- Create a script and place in
/etc/init.d(e.g/etc/init.d/myscript). The script should have the following format:
start() {
# code to start app comes here
# example: daemon program_name &
}
stop() {
# code to stop app comes here
# example: killproc program_name
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
# code to check status of app comes here
# example: status program_name
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
esac
exit 0
Later of this, ypu need ad executable permissions to the file: chmod +x myscript
The format is pretty standard and you can view existing scripts in
/etc/init.d. You can then use the script like so /etc/init.d/myscript start