shell脚本之nginx自动化脚本
时间:2020-11-03 13:37:24|栏目:Nginx|点击: 次
这个脚本,可以满足nginx开启,停止和重启的操作
#!/bin/bash
. /etc/init.d/functions
function usage() {
echo $"usage:$0 {start|stop|restart}"
exit 1
}
function start() {
/usr/local/nginx/sbin/nginx
sleep 1
if [ `netstat -antlpe | grep nginx | wc -l` -ge 0 ];then
action "nginx is started." /bin/true
else
action "nginx is started." /bin/false
fi
}
function stop() {
killall nginx &>/dev/null
sleep 1
if [ `netstat -antlpe | grep nginx | wc -l` -eq 0 ];then
action "nginx is stopped." /bin/true
else
action "nginx is stopped." /bin/false
fi
}
function main() {
if [ $# -ne 1 ];then
usage $0
fi
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
usage $0
;;
esac
}
main $*
运行试试
1.停止nginx

2.开启nginx

3.重启nginx

ok~
总结
上一篇:服务器共享文件夹设置软件、文件共享服务器软件和共享文件夹加密工具的选择
栏 目:Nginx
下一篇:磁盘阵列RAID0、RAID1和RAID5的区别和安全性介绍
本文标题:shell脚本之nginx自动化脚本
本文地址:http://www.codeinn.net/misctech/18749.html






