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
    
  • 相关阅读:
    _MSC_VER
    git之撤销修改
    vi/vim如何添加或删除多行注释
    C++ 读取文件数据和输出数据到文件
    git上传本地单独修改的文件
    Git学习笔记
    C++中类的声明
    linux中ldconfig的使用介绍
    #define 和 typedef 中的##
    find、xargs、grep基本用法
  • 原文地址:https://www.cnblogs.com/charon2/p/10572632.html
Copyright © 2011-2022 走看看