Skip to content

Instantly share code, notes, and snippets.

@chenminhua
Created July 24, 2017 13:38
Show Gist options
  • Save chenminhua/e3851f641da138f3eaf02d01f78585a3 to your computer and use it in GitHub Desktop.
Save chenminhua/e3851f641da138f3eaf02d01f78585a3 to your computer and use it in GitHub Desktop.
service
#!/bin/bash
#
# chkconfig: 2345 77 22
# description: Test Service
#
LOCKFILE=/var/lock/subsys/myservice
status() {
if [ -e $LOCKFILE ]; then
echo "Running..."
else
echo "Stopped"
fi
}
usage() {
echo "`basename $0` {start|stop|restart|status}"
}
case $1 in
start)
echo "starting..."
touch $LOCKFILE;;
stop)
echo "stopping"
rm -f $LOCKFILE &> /dev/null
;;
restart)
echo "Restarting...";;
status)
status;;
*)
usage;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment