Skip to content

Instantly share code, notes, and snippets.

@noateden
Created October 3, 2018 09:11
Show Gist options
  • Save noateden/db2ec4fc54591e873a504e768ba279e0 to your computer and use it in GitHub Desktop.
Save noateden/db2ec4fc54591e873a504e768ba279e0 to your computer and use it in GitHub Desktop.
Simple service on linux
#!/bin/bash
case "$1" in
start)
/path/to/hit.sh &
echo $!>/var/run/hit.pid
;;
stop)
kill `cat /var/run/hit.pid`
rm /var/run/hit.pid
;;
restart)
$0 stop
$0 start
;;
status)
if [ -e /var/run/hit.pid ]; then
echo hit.sh is running, pid=`cat /var/run/hit.pid`
else
echo hit.sh is NOT running
exit 1
fi
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment