1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#!/bin/bash
#
nginx_cmd=/usr/local/nginx/sbin/nginx
nginx_conf=/usr/local/nginx/conf/nginx.conf
nginx_pid_file=/usr/local/nginx/logs/nginx.pid
start(){
$nginx_cmd
if [ $? -eq 0 ];then
echo "服务nginx启动.....[ok]"
fi
}
stop(){
$nginx_cmd -s stop
}
reload(){
if $nginx_cmd -t &> /dev/null;then
$nginx_cmd -s reload
else
$nginx_cmd -t
fi
}
status(){
if [ -e $nginx_pid_file ];then
echo "服务nginx(`cat $nginx_pid_file`) is running"
else
echo "服务nginx is stopped"
fi
}
if [ -z $1 ];then
echo "使用:$0{start|stop|restart|reload|status}"
exit 9
fi
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 2
start
;;
reload)
reload
;;
*)
echo "使用:$0{start|stop|restart|reload|status}"
exit 9
;;
esac
|