龙空技术网

nginx启动脚本

科技之鹰 309

前言:

此刻同学们对“nginxsysv启动脚本”大体比较讲究,各位老铁们都需要知道一些“nginxsysv启动脚本”的相关知识。那么小编同时在网络上网罗了一些对于“nginxsysv启动脚本””的相关知识,希望各位老铁们能喜欢,各位老铁们快快来了解一下吧!

#!/bin/sh

. /etc/rc.d/init.d/functions

case $1 in

start)

if [ -f /usr/local/nginx/logs/nginx.pid ]; then

action "nginx is running" /bin/false

# echo_failure

# echo "nginx is running"

else

/usr/local/nginx/sbin/nginx

# echo_success

# echo "nginx is starting"

action "nginx is starting..." /bin/true

fi

;;

stop)

if [ -f /usr/local/nginx/logs/nginx.pid ]; then

pkill nginx

action "nginx is stopping..." /bin/true

# echo_success

# echo "nginx is stopped"

else

action "nginx is not started" /bin/false

# echo_failure

# echo "nginx is not started"

fi

;;

restart)

if [ -f /usr/local/nginx/logs/nginx.pid ]; then

pkill nginx

action "nginx is stopping..." /bin/true

# echo_success

# echo "nginx is stopped"

sleep 2

# /usr/local/nginx/sbin/nginx -s reload

action "nginx is restarting..." /bin/true

/usr/local/nginx/sbin/nginx

# echo_success

# echo "nginx is restarted"

else

action "nginx is not running" /bin/false

# echo_failure

# echo "nginx is not running"

sleep 2

# /usr/local/nginx/sbin/nginx -s reload

action "nginx is restarting..." /bin/true

/usr/local/nginx/sbin/nginx

# echo_success

# echo "nginx is started"

fi

;;

*)

echo "please input 'sh $0 start|stop|status|restart'"

;;

esac

标签: #nginxsysv启动脚本