Nginx服務啓動腳本

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


.  /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`nginx


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


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


#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
}rest


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


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


#restart
function restart(){
        stop      
        start
}function


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

相關文章
相關標籤/搜索