Skip to content

Instantly share code, notes, and snippets.

@mageddo
Created March 17, 2016 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mageddo/91888e5de573b20b3a67 to your computer and use it in GitHub Desktop.
Save mageddo/91888e5de573b20b3a67 to your computer and use it in GitHub Desktop.
Linux Service Example

Using it

cp ./whatever /etc/init.d/
sudo service whatever start
sudo service whatever stop
PROGRAM=/usr/bin/tail
PROGRAMARGS="-f /dev/null"
PIDFILE=/var/run/whatever.pid
case "$1" in
start)
echo -n "Starting whatever"
start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $PROGRAM -- $PROGRAMARGS
echo "."
;;
stop)
echo -n "Stopping whatever"
start-stop-daemon --stop --quiet --pidfile $PIDFILE
echo "."
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: /etc/init.d/xvfb {start|stop|restart}"
exit 1
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment