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

    #!bin/bash
    #功能:本脚本编写完成后,放置在/etc/init.d/目录下,就可以被 Linux 系统自动识别到该脚本.
    #如果本脚本命名为/etc/init.d/nginx,则 service nginx start 就可以启动该服务
    #作者:liusingbon
    #service nginx stop|restart|status  可以关闭,重启,查看Nginx服务
    program=/usr/local/nginx/sbin/nginx
    pid=/usr/local/nginx/logs/nginx.pid
    function start{
                   if [ -f $pid ];then
                      echo "nginx 服务已经处于开启状态"
                   else
                      $program
                   fi
                }
    function stop {
                  if [ -! -f $pid ];then
                     echo "nginx 服务已经关闭"
                  else
                     $program -s stop
                     echo "关闭服务 ok"
                  fi
                 }
    function status {
                    if [ -f $pid ];then
                       echo "服务正在运行..."
                    else
                       echo "服务已经关闭"
                    fi
    }
    case $1 in
    start)
           start;;
    stop)
           stop;;
    restart)
           stop
           sleep 1
           start;;
    status)
           status;;
    *)
           echo "你输入的语法格式错误"
    esac

  • 相关阅读:
    熬夜的朋友看一看 [转]
    配置ubuntu
    C++string类常用函数 (转)
    ArcGIS Engine栅格数据使用总结 (转)
    fstream的用法+代码
    [转] 英语飙升的好方法
    MFC 非模态对话框(转)
    十九个国内外主流的三维GIS软件(转)
    Google C++ 风格指南 中文版
    std::set用法(转)
  • 原文地址:https://www.cnblogs.com/liusingbon/p/11079515.html
Copyright © 2011-2022 走看看