#!/bin/bash
start() {
if [ `netstat -tnlp | grep -w 80 | wc -l` -eq 1 ];then
echo "Nginx is running......"
exit 1
else
/application/nginx/sbin/nginx
sleep 2
echo "Nginx start successed......"
fi
}
stop () {
if [ `netstat -tnlp | grep -w 80 | wc -l` -ne 1 ];then
echo "Nginx is not running......"
exit 1
else
/application/nginx/sbin/nginx -s stop
sleep 2
echo "Nginx stop successed......"
fi
}
reload () {
if [ `netstat -tnlp | grep -w 80 | wc -l` -ne 1 ];then
echo "Nginx is not running......"
exit 1
else
/application/nginx/sbin/nginx -s reload
sleep 2
echo "Nginx reload successed......"
fi
}
restart() {
reload
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
reload
;;
*)
echo "USAGE:$0 {start|stop|reload|restart}"
;;
esac
本文转自激情燃烧的岁月博客51CTO博客,原文链接http://blog.51cto.com/liuzhengwei521/1771899如需转载请自行联系原作者
weilovepan520