nginx启动脚本,手动编辑
nginx启动脚本,手动编辑
#! /bin/bash # chkconfig: - 85 15 # description: nginx service XDIR=/www/server/nginx DESC="nginx daemon" NAME=nginx DAEMON=$XDIR/sbin/$NAME CONFIGFILE=$XDIR/conf/$NAME.conf PIDFILE=$XDIR/logs/$NAME.pid SCRIPTNAME=$0 Xok='[\033[32m确定\033[0m]' Xno='[\033[33m失败\033[0m]' Xsb='[\033[31m失败\033[0m]' do_start() { [ -e $PIDFILE ] && { echo -e "$NAME already running " $Xno } || { $DAEMON -c $CONFIGFILE echo -e "Starting $NAME " $Xok } } do_stop() { [ -e $PIDFILE ] && { $DAEMON -s stop rm -f $PIDFILE echo -e "Stopping $NAME " $Xok sleep 1 } || { echo -e "$NAME not running" $Xsb } } do_reload() { [ -e $PIDFILE ] && { $DAEMON -s reload echo -e "$NAME reload " $Xok } || { echo -e "$NAME not running" $Xsb } } configtest(){ $DAEMON -t -c $CONFIGFILE || echo -n "config can't test" } case "$1" in "start") do_start ;; "stop") do_stop ;; r|reload|graceful) do_reload ;; "restart") do_stop do_start ;; t) echo "$NAME: check config" configtest ;; *) echo "Usage: $SCRIPTNAME {start|stop|reload|restart|t}" >&2 exit ;; esac exit 0
本文来自博客园,作者:blog-elvin-vip,转载请注明原文链接:https://www.cnblogs.com/elvi/p/7717979.html