#! /bin/sh
# chkconfig: 35 85 15
# description: This is nginx start and stop script
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/sbin/$NAME
CONFIGFILE=/etc/nginx/$NAME.conf
PIDFILE=/var/run/nginx/$NAME.pid
SCRIPTNAME=/etc/rc.d/init.d/$NAME
[ -x "$DAEMON" ] || exit 0
start() {
$DAEMON -c $CONFIGFILE || echo -n "nginx already running"
}
stop() {
kill -INT `cat $PIDFILE` || echo -n "nginx not running"
}
reload() {
kill -HUP `cat $PIDFILE` || echo -n "nginx can‘t reload"
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
stop
echo "."
;;
reload|graceful)
echo -n "Reloading $DESC configuration..."
reload
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
stop
start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
exit 3
;;
esac
exit 0
nginx 启停脚本