标签:nginx启动脚本
#!/bin/bash
#chkconfig - 80 90
pid="/usr/local/nginx/logs/nginx.pid"
mynaginx="/usr/local/nginx/sbin/nginx"
cecho(){
echo -e "\033[$1m$2\033[0m"
}
a=33;b=31
start(){
if [ -f $pid ];then
cecho $a "nginx正在运行..."
else
/usr/local/nginx/sbin/nginx
sleep 5
if [ -f $pid ];then
cecho $a "nginx启动成功..."
else
cecho $b "nginx启动失败..."
fi
fi
}
stop(){
if [ ! -f $pid ];then
cecho $b "nginx处于停运状态..."
else
kill `cat /usr/local/nginx/logs/nginx.pid`
sleep 5
if [ -f $pid ];then
cecho $b "nginx关闭失败..."
else
cecho $a "nginx关闭成功..."
fi
fi
}
status(){
if [ -f $pid ];then
cecho $a "nginx正在运行中..."
else
cecho $b "nginx处于关闭状态..."
fi
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 2
start
;;
status)
status
;;
*)
echo "Usage: nginx {start|stop|restart|status}"
esac
标签:nginx启动脚本
原文地址:http://lisp521.blog.51cto.com/11599245/1899620