首页 > 其他 > 详细

nginx启动脚本

时间:2017-02-20 23:13:12      阅读:264      评论:0      收藏:0      [点我收藏+]

#!/bin/bash
#chkconfig - 80 90
pid="/usr/local/nginx/logs/nginx.pid"
mynaginx="/usr/local/nginx/sbin/nginx"

cecho(){
    echo -e "\033[$1m$2\033[0m"
}
a=33;b=31
start(){
    if [ -f $pid ];then
        cecho $a "nginx正在运行..."
    else    
        /usr/local/nginx/sbin/nginx
        sleep 5
        if [ -f $pid ];then
            cecho $a "nginx启动成功..."
        else
            cecho $b  "nginx启动失败..."
        fi        

    fi
}
stop(){
    if [ ! -f $pid ];then
        cecho $b  "nginx处于停运状态..."
    else
        kill `cat /usr/local/nginx/logs/nginx.pid`
        sleep 5
                if [ -f $pid ];then
                        cecho $b "nginx关闭失败..."
                else
                        cecho $a  "nginx关闭成功..."
        fi
    fi

}
status(){
        if [ -f $pid ];then
                        cecho $a "nginx正在运行中..."
                else
                        cecho $b  "nginx处于关闭状态..."
        fi
}
case $1 in
start)
    start
    ;;
stop)
    stop
    ;;
restart)
    stop
    sleep 2
    start
    ;;
status)
    status
    ;;
*)
    echo "Usage: nginx {start|stop|restart|status}"
esac

nginx启动脚本

原文:http://lisp521.blog.51cto.com/11599245/1899620

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!