shell-nginx启动脚本

3年前 (2017-05-26) gtj linux 0评论 已收录 681℃

脚本启动
#!/bin/bash

. /etc/init.d/functions
path=/usr/local/nginx/sbin/nginx
if [ $# -ne 1 ];then
echo "please input {status|start|stop|restart|reload}"
fi
nginx_status(){
status=`lsof -i:80|wc -l`
if [ $status -gt 2 ];then
echo "nginx is running "
else
echo "nginx no running"
fi
}
##################
nginx_start(){
$path
if [ $? -eq 0 ];then
action "nginx start" /bin/true
else
action "nginx no start" /bin/false
fi
}
nginx_stop(){
$path -s stop
if [ $? -eq 0 ];then
action "nginx stop" /bin/true
else
action "nginx no stop" /bin/false
fi
}
nginx_restart(){
$path -s stop
if [ $? -eq 0 ];then
action "nginx stop" /bin/true
else
action "nginx no stop" /bin/false
fi
sleep 3
$path
if [ $? -eq 0 ];then
action "nginx start" /bin/true
else
action "nginx no start" /bin/false
fi
}
nginx_reload(){
$path -s reload
if [ $? -eq 0 ];then
action "nginx reload" /bin/true
else
action "nginx no reload" /bin/false
fi
}
case "$1" in
start)
nginx_start
;;
stop)
nginx_stop
;;
restart)
nginx_restart
;;
reload)
nginx_reload
;;
status)
nginx_status
;;
esac

参考这个脚本可以很好的写其他的软件启动关闭的脚本

博主

这货来去如风,什么鬼都没留下!!!

相关推荐

嗨、骚年、快来消灭0回复。

×
订阅图标按钮
Less is more!!!