-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx_run.sh
59 lines (50 loc) · 1.02 KB
/
nginx_run.sh
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
#!/bin/bash
#
# 此参数都可以进行修改
nginx_cmd="/usr/local/nginx/sbin/nginx"
nginx_pid="/usr/local/nginx/logs/nginx.pid"
if [ $# -eq 0 ];then
echo "用法: $0 {start|stop|restart|status}"
exit 100
fi
case $1 in
start)
$nginx_cmd
if [ $? -eq 0 ];then
echo "nginx启动成功!!!"
fi
;;
stop)
$nginx_cmd -s stop
netstat -antp|grep nginx &> /dev/null
if [ $? -ne 0 ];then
echo "nginx关闭成功!!!"
fi
;;
restart)
$nginx_cmd -s stop
echo "正在关闭nginx......"
netstat -antp|grep nginx &> /dev/null
if [ $? -ne 0 ];then
echo "nginx关闭成功!!!"
fi
sleep 1
$nginx_cmd
echo "正在启动nginx......"
netstat -antp|grep nginx &> /dev/null
if [ $? -eq 0 ];then
echo "nginx启动成功!!!"
fi
;;
status)
if [ -e $nginx_pid ];then
echo "nginx(PID $(cat $nginx_pid))正在运行!!!"
else
echo "nginx已经关闭!!!"
fi
;;
*)
echo "选择错误!!!"
echo "用法: $0 {start|stop|restart|status}"
;;
esac