Nginx的启动,关闭,重启脚本

本文介绍了一个用于控制nginx服务启动、重启及关闭的Shell脚本,该脚本适用于Solaris 10系统,并需由超级用户执行。通过简单的命令参数即可实现对nginx进程的有效管理。

以下是我写的控制nginx启动的,关闭,重启的shell脚本,经测试,在Solaris 10 系统下可以正常运行,不过这个脚本需要由超级用户执行。

以下代码片段的漂亮边框和背景是在秀代码这个网站弄的,呵呵。http://xiudaima.appspot.com/

BASH CODE :nginxControl

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

#!/usr/bin/sh

NGINX_HOME=/usr/local/nginx
if [ -n "$1" ]
then
case $1 in
1)
echo "startup nginx"
if [ -n "$2" ]
then
$NGINX_HOME/sbin/nginx -c "$2"
echo "started"
else
echo "should have the second argument"
fi
;;
2)
echo "reload nginx"
read nginx_pid < $NGINX_HOME/logs/nginx.pid
echo "the main pid of nginx is $nginx_pid"
echo "restart nginx now"
kill -HUP $nginx_pid
echo "restarted"
;;
3)
echo "shut down nginx"
read nginx_pid < $NGINX_HOME/logs/nginx.pid
echo "the main pid of nginx is $nginx_pid"
echo "shut down nginx now"
kill -TERM $nginx_pid
echo "shut down"
;;
*)
echo "error argument." 
;;
esac
else
echo "no arguments,should be one argument."
exit 1
fi

分类:  Solaris_Learning


本文转自leipei博客园博客,原文链接:http://www.cnblogs.com/leipei2352/archive/2011/03/13/1982802.html,如需转载请自行联系原作者
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值