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

Nginx管理脚本

时间:2017-05-12 01:42:44      阅读:117      评论:0      收藏:0      [点我收藏+]

标签:pid   chkconfig   start   $?   val   stopped   app   started   else   

 1 #!/bin/bash
 2 # chkconfig: 2345 40 98
 3 # description: Start/Stop Nginx server
 4 
 5 path=/application/nginx/sbin
 6 pid=/application/nginx/logs/nginx.pid
 7 RETVAL=0
 8 
 9 . /etc/init.d/functions
10 
11 start(){
12     if [ ! -f $pid ];then
13         $path/nginx
14         RETVAL=$?
15         if [ $RETVAL -eq 0 ];then
16             action "nginx is started" /bin/true
17             return $RETVAL
18         else
19             action "nginx is started" /bin/false
20             return $RETVAL
21         fi
22     else
23         echo "nginx is running"
24         return 0
25     fi
26 }
27 stop(){
28     if [ -f $pid ];then
29         $path/nginx -s stop
30          RETVAL=$?
31         if [ $RETVAL -eq 0 ];then
32             action "nginx is stopped" /bin/true
33             return $RETVAL
34         else
35             action "nginx is stopped" /bin/false
36             return $RETVAL
37         fi
38     else
39         echo "nginx is no running"
40         return $RETVAL
41     fi
42 }
43  
44 case "$1" in
45     start)
46         start
47         RETVAL=$?
48         ;;
49     stop)
50         stop
51         RETVAL=$?
52         ;;
53     restart)
54          stop
55              sleep 1
56          start
57          RETVAL=$?
58          ;;
59     *)
60          echo $"Usage: $0 {start|stop|restart|reload}"
61          exit 1
62 esac
63 exit $RETVAL

 

Nginx管理脚本

标签:pid   chkconfig   start   $?   val   stopped   app   started   else   

原文地址:http://www.cnblogs.com/standby/p/6843520.html

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