#!/bin/bash
# init.d/nginx
#
# and symbolic its link
#
# /usr/local/nginx/sbin/nginx
#
# System startup script for the nginx daemon
#
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: no
# Required-Stop: no
# Should-Start: no
# Should-Stop: no
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: Start the nginx server daemon
### END INIT INFO
. /etc/rc.status
rc_reset
NGINX_BIN=/usr/local/nginx/sbin/nginx
NGINX_PID_FILE=/var/run/nginx.pid
function nginx_start {
echo -n "Starting nginx daemon"
startproc -p $NGINX_PID_FILE -t 1 $NGINX_BIN
rc_status -v
}
function nginx_stop {
echo -n "Shutting down nginx daemon"
killproc -p $NGINX_PID_FILE -TERM $NGINX_BIN
rc_status -v
}
function nginx_reload {
echo -n "Reload service rsync"
killproc -p $NGINX_PID_FILE -HUP $NGINX_BIN
rc_status -v
}
case $1 in
start)
nginx_start
;;
stop)
nginx_stop
;;
restart)
nginx_stop
nginx_start
;;
reload)
nginx_reload
;;
*)
echo "Useage $0 start|stop|restart|reload "
;;
esac
设置35极别开机启动
DJFW-web01:/etc/init.d # ln -sf /etc/init.d/nginx /etc/rc.d/rc3.d/S22nginx
DJFW-web01:/etc/init.d # ln -sf /etc/init.d/nginx /etc/rc.d/rc3.d/K22nginx
DJFW-web01:/etc/init.d # ln -sf /etc/init.d/nginx /etc/rc.d/rc5.d/K22nginx
DJFW-web01:/etc/init.d # ln -sf /etc/init.d/nginx /etc/rc.d/rc5.d/S22nginx
22:查看/etc/rc.d/rc3.d/目录最后一位数字,再向后加就可以了。
DJFW-web01:/etc/init.d # chkconfig --list | grep nginx
nginx 0:off 1:off 2:off 3:on 4:off 5:on 6:off