码迷,mamicode.com
首页 > 其他好文 > 详细

脚本控制nginx的启动,关闭,重载等

时间:2016-05-10 18:53:00      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:脚本控制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的启动,关闭,重载等

标签:脚本控制nginx

原文地址:http://liuzhengwei521.blog.51cto.com/4855442/1771899

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!