标签:脚本控制nginx
#!/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
本文出自 “激情燃烧的岁月” 博客,请务必保留此出处http://liuzhengwei521.blog.51cto.com/4855442/1771899
标签:脚本控制nginx
原文地址:http://liuzhengwei521.blog.51cto.com/4855442/1771899