码迷,mamicode.com
首页 > 其他好文 > 详细

Nginx服务启动脚本

时间:2015-12-26 23:45:12      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:version   action   started   email   status   

#!/bin/sh
#filename:rsync_start.sh
#date:2015-12-23
#作者:linuxzkq
#Email:1729294227@qq.com
#version:v1.0


.  /etc/init.d/functions
path=/application/nginx/sbin/nginx
pid=/application/nginx/logs/nginx.pid
process=`ps -ef|grep nginx|grep -v grep|wc -l`


#USAGE
function USAGE(){
    echo "USAGE:$0 {start|stop|restart|reload|status}"
    exit 0
}


#start
function start(){
     $path &>/dev/null
     if [ $? -eq 0 ];then
         action "Nginx is started:" /bin/true
     else
         action "Nginx is started:" /bin/false
     fi
}               


#stop
function stop(){
     if [ $process -ne 0 ] && [ -s "$pid" ];then
          killall nginx
          action "Nginx is stopped:" /bin/true
     else
          action "Nginx is stopped:" /bin/false
     fi
}


#reload
function reload(){
      $path -s reload
}


#status
function status(){
       if [ $process -ne 0 ] && [ -s "$pid" ];then
         echo "Nginx is running."
       else
         echo "No Nginx Process!"
       fi
}


#restart
function restart(){
        stop       
        start
}


case "$1" in
     start)
       start
       ;;
      stop)
       stop
       ;;
    status)
       status
       ;;
   restart) 
       restart
       ;;
    reload)
       reload
       ;;
         *)
       echo "Error,Please use an USAGE!"
       USAGE
       ;;
esac


本文出自 “就爱运维” 博客,请务必保留此出处http://92yunwei.blog.51cto.com/11037409/1728637

Nginx服务启动脚本

标签:version   action   started   email   status   

原文地址:http://92yunwei.blog.51cto.com/11037409/1728637

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