生活是美好的

 找回密碼
 立即註冊
搜索
查看: 446|回復: 0

Nginx启动、关闭、重新加载脚本

[複製鏈接]

112

主題

112

帖子

453

積分

管理員

Rank: 9Rank: 9Rank: 9

積分
453
發表於 2019-12-11 14:54:47 | 顯示全部樓層 |閱讀模式
#! /bin/sh
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the nginx web server

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/local/nginx/sbin/$NAME
CONFIGFILE=/usr/local/nginx/conf/$NAME.conf
PIDFILE=/usr/local/nginx/logs/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

set -e
[ -x "$DAEMON" ] || exit 0

do_start() {
$DAEMON -c $CONFIGFILE || echo -n "nginx already running"
}

do_stop() {
kill -INT `cat $PIDFILE` || echo -n "nginx not running"
}

do_reload() {
kill -HUP `cat $PIDFILE` || echo -n "nginx can't reload"
}

case "$1" in
start)
echo -n "Starting $DESC: $NAME"
do_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
do_stop
echo "."
;;
reload|graceful)
echo -n "Reloading $DESC configuration..."
do_reload
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
do_stop
do_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
exit 3
;;
esac

exit 0


##########################
可以用以下方式来执行此脚本:
*先chmod +x /etc/init.d/nginx有执行权限
     /etc/init.d/nginx start
     /etc/init.d/nginx stop
    /etc/init.d/nginx reload
    /etc/init.d/nginx restart





回復

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即註冊

本版積分規則

GMT+8, 2025-4-18 17:29 , Processed in 0.520582 second(s), 21 queries .

© 本站内容由個人原創或轉載,如果侵犯了您的合法權益,請及時聯繫處理! Email:lyb@qq.com

快速回復 返回頂部 返回列表