码迷,mamicode.com
首页 > 系统相关 > 详细

shell -nginx启动脚本

时间:2015-08-09 20:52:28      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:

#########################################################################
# File Name: nginx.sh
# Author: dty
# mail: 576786031@qq.com
# Created Time: Sun 09 Aug 2015 06:02:17 PM CST
#########################################################################
#!/bin/bash
. /etc/rc.d/init.d/functions
nginx=/usr/local/nginx/sbin/nginx
PID=/usr/local/nginx/logs/nginx.pid
prog=nginx
RETVAL=0
start(){
    echo -n "Starting $prog ....."
    $nginx -t &> /dev/null
    if [ "$?" -eq 0 ];then
        $nginx &>/dev/null && success || failure
    fi
    echo
    RETVAL=$?
    return $RETVAL
}

stop(){
    echo -n "Stopping $prog:"
    $nginx -s stop &> /dev/null && success ||failure
    echo
    RETVAL=$?
    return $RETVAL
}

reload(){
    echo -n "Stopping $prog:"
    $nginx -s reload &> /dev/null && success ||failure
    echo
    RETVAL=?
    return $RETVAL
}
case $1 in
    start)
        start;;
    stop)
        stop;;
    restart)
        stop
        start;;
    reload)
        reload
        ;;
    status)
        status -p ${PID} $nginx
        RETVAL=$?
        ;;
    help)
        $nginx -h
        RETVAL=$?
        ;;
        *)
            echo usage(start|stop|restart|help|reload|);;
    esac
    exit $RETVAL


shell -nginx启动脚本

标签:

原文地址:http://my.oschina.net/loveleaf/blog/489797

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