원본 nginx 시작 스 크 립 트

990 단어
vim nginx
#!/bin/bash
# chkconfig: 2345 99 20
pid="/usr/local/nginx/logs/nginx.pid" #nginx pid
state="/usr/local/nginx/sbin/nginx"   #nginx      
case $1 in
start)
   netstat -anpt|grep nginx &>/dev/null  #  nginx    
   if [ $? -eq 0 ];then       #     
      exit
   else		                  #      
      $state -t &>/dev/null    #        
      if [ $? -eq 0 ];then
         $state
      else
         $state -t     #          
      fi
   fi
;;
stop)
   cat $pid &>/dev/null  #     nginx pid
   if [ $? -eq 0 ];then   #   
      kill -15 `cat $pid`
   else    #    
      exit
   fi
;;
restart)
   cat $pid &>/dev/null
   if [ $? -eq 0 ];then
      kill -15 `cat $pid`
      $state
   else
      $state -t &>/dev/null
      if [ $? -eq 0 ];then
         $state
      else
         $state -t
      fi
   fi
;;
*)
   echo "   :|start|stop|restart|"
;;
esac

chmod +x nginx mv nginx /etc/init.d/nginx

좋은 웹페이지 즐겨찾기