创建独立守护进程(
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
chckconfig --add myserver
)
转载于:https://blog.51cto.com/ngames/1555248