nginx启动脚本

#!/bin/bash
#chkconfig: 3 85 15
#description: nginx
DAEMON=/usr/local/nginx/sbin/nginx
[ -x $DAEMON ] || exit 1
d_start() {
    $DAEMON && echo "ok!"
}
d_stop() {
    $DAEMON -s stop && echo "ok!"
}
d_reload() {
    $DAEMON -s reload && echo "ok!"
}
case "$1" in
start)
    echo -n "Starting..."
    d_start
;;
stop)
    echo -n "Stopping..."
    d_stop
;;
reload)
    echo -n "Reloading..."
    d_reload
;;
restart)
    echo -n "Stopping..."
    d_stop
    sleep 2
    echo -n "Starting..."
    d_start
;;
*)
    echo "Usage: service nginx {start|stop|restart|reload}" >&2
    exit 1
;;
esac
exit 0

使用方法:

   保存以上脚本为nginx

   添加可执行权限:chmod 700 /etc/init.d/nginx

   添加到chkconfig管理:chkconfig --add nginx

   添加后默认为“level 3”启动

你可能感兴趣的:(nginx启动脚本)