#!/bin/bash
#
# chkconfig: 2345 20 80
# description: autoruntest
# processname: /etc/rc.d/init.d/sysm
EXEC_PATH=/root/project/sys_monitor
EXEC=sysm
PID_FILE=/var/run/sysm.pid
DAEMON=ps ax |grep java |awk '{print $1}'
# Source function library.
. /etc/rc.d/init.d/functions
if ! [ -x $EXEC_PATH/$EXEC ] ; then
echo "ERROR: $EXEC_PATH/$EXEC not found"
exit 1
fi
stop()
{
echo "Stoping $EXEC ..."
killall $DAEMON >/dev/ null
usleep 100
echo "Shutting down $EXEC: [ OK ]"
}
start()
{
echo "Starting $EXEC ..."
$DAEMON > /dev/ null &
usleep 100
echo "Starting $EXEC: [ OK ]"
}
restart()
{
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status -p $PID_FILE $DAEMON
;;
*)
echo "Usage: service $EXEC {start|stop|restart|status}"
exit 1
esac
exit $?
#
# chkconfig: 2345 20 80
# description: autoruntest
# processname: /etc/rc.d/init.d/sysm
EXEC_PATH=/root/project/sys_monitor
EXEC=sysm
PID_FILE=/var/run/sysm.pid
DAEMON=ps ax |grep java |awk '{print $1}'
# Source function library.
. /etc/rc.d/init.d/functions
if ! [ -x $EXEC_PATH/$EXEC ] ; then
echo "ERROR: $EXEC_PATH/$EXEC not found"
exit 1
fi
stop()
{
echo "Stoping $EXEC ..."
killall $DAEMON >/dev/ null
usleep 100
echo "Shutting down $EXEC: [ OK ]"
}
start()
{
echo "Starting $EXEC ..."
$DAEMON > /dev/ null &
usleep 100
echo "Starting $EXEC: [ OK ]"
}
restart()
{
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status -p $PID_FILE $DAEMON
;;
*)
echo "Usage: service $EXEC {start|stop|restart|status}"
exit 1
esac
exit $?
本文转自 珏石头 51CTO博客,原文链接:http://blog.51cto.com/gavinshaw/305626,如需转载请自行联系原作者