那个剧本,否以餍足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
两.封闭nginx
3.重封nginx
以上便是nginx自发化剧本若何怎样写的具体形式,更多请存眷萤水红IT仄台其余相闭文章!
发表评论 取消回复