zoukankan      html  css  js  c++  java
  • nginx启动脚本

    启动脚本

    #!/bin/bash
    WORK_DIR=/data/nginx
    COMM_DIR=$WORK_DIR/sbin/nginx
    NAME=nginx
    PID=$WORK_DIR/logs/nginx.pid
    
    
    start() {
    if [ -f $PID ];
    then
        echo "nginx is running"
    else
    $COMM_DIR
       if [ -f $PID ];
         then
            echo "nginx is started"
            exit 0
          else
            echo "nginx start is bad"
            exit 1
      fi
    fi
    
    }
    
    stop() {
    if [ -f $PID ];
      then
        $COMM_DIR -s stop
        echo "nginx is stoped"
      else
        echo "nginx: [error] open() "/data/nginx/logs/nginx.pid" failed (2: No such file or directory)"
        exit 1
    fi
           
    
    }
    
    restart() {
    if [ ! -f $PID ];
      then
        echo "nginx: [error] open() "/data/nginx/logs/nginx.pid" failed (2: No such file or directory)"
      else
         $COMM_DIR -s stop
         sleep 3
         $COMM_DIR
    fi
    }
    
    
    reload() {
    if [ ! -f $PID ];
      then
        echo "nginx: [error] open() "/data/nginx/logs/nginx.pid" failed (2: No such file or directory)"
      else
         $COMM_DIR -s reload
    fi
    }
    
    chk() {
    if [ ! -f $PID ]
      then
         echo "nginx: [error] open() "/data/nginx/logs/nginx.pid" failed (2: No such file or directory"
      else
        $COMM_DIR -t
    fi
    }
    
    
    case $1 in
    start)
        start
    ;;
    stop)
        stop
    ;;
    restart)
        restart
    ;;
    reload)
         reload
    
    ;;
    chk)
       chk
    ;;
    *)
    echo "Usage:$0 {start|stop|restart|reload|ehk}"
    ;;
    esac
    
  • 相关阅读:
    【Leetcode】113Path Sum II
    【leetcode】112. Path Sum
    virtualbox 中安装win7虚拟机
    制作一个vagrant的win7 box
    socket编程
    异常处理
    strip(),replace()和re.sub()用法
    面象对象 高阶篇
    面象对象 基础篇
    Subprocess模块介绍
  • 原文地址:https://www.cnblogs.com/charon2/p/10572632.html
Copyright © 2011-2022 走看看