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='[ 33[32m确定 33[0m]' Xno='[ 33[33m失败 33[0m]' Xsb='[ 33[31m失败 33[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