Skip to content

Instantly share code, notes, and snippets.

@rkaneko
Created January 28, 2013 07:39
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 rkaneko/4653700 to your computer and use it in GitHub Desktop.
Save rkaneko/4653700 to your computer and use it in GitHub Desktop.
Daemon for jetty on CentOS .
#!/bin/bash
#
# chkconfig: 345 99 01
# description: Startup script for the jetty
# Source function library.
. /etc/rc.d/init.d/functions
start() {
if [ -z `/usr/bin/pgrep -f "java -jar start.jar"` ]; then
echo "Starting jetty..."
cd /usr/local/jetty
java -jar start.jar &
else
echo "jetty is already running"
fi
}
stop() {
if [ ! -z `/usr/bin/pgrep -f "java -jar start.jar"` ]; then
echo "Stopping jetty..."
kill -9 `/usr/bin/pgrep -f "java -jar start.jar"`
echo "jetty stopped."
else
echo "jetty is not running"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment