
这个脚本,可以满足nginx开启,停止和重启的 *** 作
#!/bin/bash
. /etc/init.d/functions
function usage() {
echo $"usage:1.停止nginx {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 2.开启nginx
fi
case in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
usage 3.重启nginx;; esac } main $*
运行试试
总结ok~


评论列表(0条)