nginx启动脚本
Posted dccrussell
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx启动脚本相关的知识,希望对你有一定的参考价值。
#!/bin/bash start_file="/usr/local/nginx/sbin/nginx" PID="/usr/local/nginx/logs/nginx.pid" #start start(){ if [ -f $PID ];then echo "nginx already start" exit 1 else $start_file && echo "start success" || echo "start failed" fi } stop(){ if [ -f $PID ];then $start_file -s stop && echo "stop success" || echo "stop failed" else echo "nginx already stop" fi } status(){ if [ -f $PID ];then echo "nginx is running" else echo "nginx is dead" fi } #main case $1 in start) start;; stop) stop;; status) status;; restart) stop sleep 1 start;; *) echo "usage:$0 start|stop|status|restart";; esac
stop和start之间最好有停留时间,因为防止nginx没有完全关闭
以上是关于nginx启动脚本的主要内容,如果未能解决你的问题,请参考以下文章