天天看點

建立獨立守護程序腳本

建立獨立守護程序(

vim myserver.sh

#!/bin/bash

#chkconfig:2345 77 22

#description:test server

lockfile=/var/lock/subsys/mychkconfig

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 "stoping..."

    rm -f $lockfile &> /dev/null

status)

    status

restart)

    echo "restarting..."

*)

    usage

esac

mv myserver.sh /etc/rc.d/init.d/myserver

繼續閱讀