Skip to content

Instantly share code, notes, and snippets.

@hornc
Last active September 27, 2016 03:33
Show Gist options
  • Save hornc/9fcff5713bc54a67cdc225a56776e957 to your computer and use it in GitHub Desktop.
Save hornc/9fcff5713bc54a67cdc225a56776e957 to your computer and use it in GitHub Desktop.
basic sysv service statup script for init.d
#!/bin/bash
#
# /etc/rc.d/init.d/<servicename>
servicename="<servicename"
script="/home/root/servicename.sh"
case "$1" in
start)
echo -n "Starting $servicename service: "
$script > /dev/null 2>&1 &
;;
stop)
echo -n "Shutting down $servicename service: "
;;
status)
# <rough and ready report of the status of the service using ps output>
ps aux | grep "[ ]$script"
;;
restart)
# <restart the daemons, normally with $0 stop; $0 start>
;;
*)
echo "Usage: $servicename {start|stop|status|restart}"
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment