Linux中nginx服務器啟動腳本
阿新 • • 發佈:2017-07-15
nginx啟動腳本 linux shell腳本
Linux中nginx服務器啟動腳本,將此腳本放入/etc/init.d/目錄下,進行啟動和關閉,並用chkconfig命令將nginx加入到chkconfig管理中,設置開機自啟動。
詳細腳本如下:
#!/bin/bash #author wangning #date 2017-7-14 #qq 1198143315 #Email [email protected] [ -f /etc/init.d/functions ] && . /etc/init.d/functions #chkconfig: 2345 46 78 #description: nginx service manage #################define variable################################################ num=`ps -ef|grep worker|grep -v grep|wc -l` nginx=/application/nginx/sbin/nginx ########################start stop restart reload functions########################## nginx_start(){ if [ $num -gt 5 ];then echo "the nginx service has running" exit 1 else $nginx &>/dev/null action "start nginx" /bin/true fi } nginx_stop(){ if [ $num -lt 5 ];then echo "the nginx service has stoped" exit 2 else $nginx -s stop action "stop nginx" /bin/true fi } nginx_restart(){ $nginx -s stop $nginx action "restart nginx" /bin/true } nginx_reload(){ $nginx -s reload action "reload nginx" /bin/true } #########################nginx manage########################################### case $1 in start) nginx_start ;; stop) nginx_stop ;; restart) nginx_restart ;; reload) nginx_reload ;; *) echo "USAGE:$0 {start|stop|restart|reload}" esac
本文出自 “飛奔的駱駝” 博客,請務必保留此出處http://wn2100.blog.51cto.com/9915310/1947817
Linux中nginx服務器啟動腳本