nginx启动脚本,手动编辑
#! /bin/bash
# chkconfig: -
# 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=$ 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
} || {
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}" >&
exit
;;
esac
exit