创建server 管理脚本

#!/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 $?

本文出自 “望月飞鱼” 博客,谢绝转载!

你可能感兴趣的:(server,职场,自启动,休闲,pif)