其他分享
首页 > 其他分享> > 设置自己的服务为自动重启

设置自己的服务为自动重启

作者:互联网

#!/bin/bash

description: testsrv

chkconfig: - 99 1

. /etc/init.d/functions
SCRIPT_NAME=testsrv
start(){
if [ -f /var/lock/subsys/$SCRIPT_NAME ];then
action " starting testsrv: "
else
touch /var/lock/subsys/$SCRIPT_NAME
action " starting testsrv: "
fi
}
stop(){
if [ -f /var/lock/subsys/$SCRIPT_NAME ];then
rm -rf /var/lock/subsys/$SCRIPT_NAME
action " stoping testsrv: " false
else
action " stoping testsrv: " false

       fi

}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
if [ -f /var/lock/subsys/$SCRIPT_NAME ];then
echo $SCRIPT_NAME is starting
else
echo $SCRIPT_NAME is stoping
fi
;;
*)
echo service testsrv {start|stop|restart}
esac

标签:testsrv,NAME,SCRIPT,lock,重启,自动,设置,var,subsys
来源: http://blog.51cto.com/14114496/2343680