PS:脚本内容如下 #!/bin/bash #chkconfig: 2345 97 25 #description nginx-server-scryt nginx=/usr/local/nginx/sbin/nginx case "$1" in start) netstat -anlpt | grep nginx if [ $? -eq 0 ] then echo "nginx service running!" else echo "nginx service not running!" $nginx fi ;; restart) $nginx -s reload if [ $? -eq 0 ] then echo "nginx server is begin restart" else echo "nginx server restart" fi ;; stop) $nginx -s stop if [ $? -eq 0 ] then echo "nginx server is stop" else echo "nginx server stop,try again" fi ;; status) netstat -anlpt | grep nginx if [ $? -eq 0 ] then echo "nginx server is running!" else echo "nginx server is not running,try to restart" fi ;; *) echo "Please enter (start|restart|stop|status)" ;; esac exit 0