码迷,mamicode.com
首页 > 其他好文 > 详细

nginx启动脚本

时间:2018-05-27 14:51:59      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:之间   没有   rest   dea   amp   完全   already   bash   led   

#!/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启动脚本

标签:之间   没有   rest   dea   amp   完全   already   bash   led   

原文地址:https://www.cnblogs.com/dccrussell/p/9095847.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!