nginx启动和停止脚本
2009-06-10 18:28
351 查看
#!/bin/bash
# Nginx service controll
# chkconfig: - 85 15
# description: A faster www server
. /etc/rc.d/init.d/functions
prog="Nginx"
prog_name="nginx"
pid_file="/usr/local/nginx/nginx.pid"
bin_file="/usr/local/nginx/sbin/$prog_name"
user="httpd"
group="httpd"
conf_file="/usr/local/nginx/conf/nginx.conf"
test_config(){
# Test configuration
$bin_file -t -c $conf_file
}
start(){
if [ -f "$pid_file" ]; then
action $"Startting $prog: " /bin/false
echo "$prog is running ..."
exit 1
else
$bin_file -c $conf_file>/dev/null
if [ -f "$pid_file" ]; then
action $"Startting $prog: " /bin/true
else
action $"Startting $prog: " /bin/false
echo "Some unexcepted errors occupied ..."
fi
fi
}
stop(){
if [ -f "$pid_file" ]; then
pid=`cat "$pid_file"`
if kill -0 $pid 2>/dev/null; then
kill $pid
rm -rf $pid_file
action $"Stopping $prog: " /bin/true
else
action $"Stopping $prog: " /bin/false
echo "$prog is not running, but PID file exists"
exit 1
fi
else
action $"Stoppng $prog: " /bin/false
echo "$prog is not running ..."
exit 1
fi
}
force_stop(){
killall $prog_name>/dev/null
rm -rf $pid_file
sleep 2
action $"Force stopping $prog: " /bin/true
}
restart(){
stop
start
}
force_reload(){
force_stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
force_reload)
force_reload
;;
force_stop)
force_stop
;;
test)
test_config
;;
*)
echo $"Usage $prog: {start|stop|restart|test|force_stop|force_reload}"
exit 1
;;
esac
exit 0
# Nginx service controll
# chkconfig: - 85 15
# description: A faster www server
. /etc/rc.d/init.d/functions
prog="Nginx"
prog_name="nginx"
pid_file="/usr/local/nginx/nginx.pid"
bin_file="/usr/local/nginx/sbin/$prog_name"
user="httpd"
group="httpd"
conf_file="/usr/local/nginx/conf/nginx.conf"
test_config(){
# Test configuration
$bin_file -t -c $conf_file
}
start(){
if [ -f "$pid_file" ]; then
action $"Startting $prog: " /bin/false
echo "$prog is running ..."
exit 1
else
$bin_file -c $conf_file>/dev/null
if [ -f "$pid_file" ]; then
action $"Startting $prog: " /bin/true
else
action $"Startting $prog: " /bin/false
echo "Some unexcepted errors occupied ..."
fi
fi
}
stop(){
if [ -f "$pid_file" ]; then
pid=`cat "$pid_file"`
if kill -0 $pid 2>/dev/null; then
kill $pid
rm -rf $pid_file
action $"Stopping $prog: " /bin/true
else
action $"Stopping $prog: " /bin/false
echo "$prog is not running, but PID file exists"
exit 1
fi
else
action $"Stoppng $prog: " /bin/false
echo "$prog is not running ..."
exit 1
fi
}
force_stop(){
killall $prog_name>/dev/null
rm -rf $pid_file
sleep 2
action $"Force stopping $prog: " /bin/true
}
restart(){
stop
start
}
force_reload(){
force_stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
force_reload)
force_reload
;;
force_stop)
force_stop
;;
test)
test_config
;;
*)
echo $"Usage $prog: {start|stop|restart|test|force_stop|force_reload}"
exit 1
;;
esac
exit 0
相关文章推荐
- Nginx 启动/停止/状态等服务脚本
- nginx启动 停止 重启等 管理脚本
- Nginx和PHP-FPM的启动、重启、停止脚本分享
- Nginx和PHP-FPM的启动、重启、停止脚本分享
- Nginx和PHP-FPM的启动、重启、停止脚本分享
- Nginx 启动、停止服务的脚本
- Nginx和PHP-FPM的启动、重启、停止脚本分享
- Nginx启动停止脚本
- nginx & php-cgi 停止和启动脚本
- Nginx启动、重启、停止脚本
- Nginx和PHP-FPM的启动、重启、停止脚本
- Nginx 启动、停止服务的脚本
- Nginx服务启动、停止和重启等操作的SHELL脚本
- Nginx和PHP-FPM的启动、重启、停止脚本分享
- Nginx和PHP-FPM的启动、重启、停止脚本分享
- linux下nginx启动停止重启控制脚本
- Nginx和PHP-FPM的启动、重启、停止脚本分享
- nginx启动/重启/停止脚本
- nginx启动、重启、停止脚本
- Nginx和PHP-FPM的启动、重启、停止脚本分享(转)