Skip to content

Instantly share code, notes, and snippets.

@e0da
Created November 16, 2012 23:11
Show Gist options
  • Save e0da/4091780 to your computer and use it in GitHub Desktop.
Save e0da/4091780 to your computer and use it in GitHub Desktop.
Basic SysV-compatible init script
#!/bin/sh
run_string="command to run program"
kill_match="string to match in ps -ef to find this process"
start() {
$run_string
}
stop() {
pid=`ps -ef | grep "$kill_match" | grep -v grep | awk '{print $2}'`
kill $pid
}
restart() {
stop
start
}
case "$1" in
'start')
start ;;
'stop')
stop ;;
'restart')
restart ;;
*)
echo "Usage: $0 start|stop|restart"
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment