Nginx服务启动脚本
2015-12-23 17:29
681 查看
#!/bin/sh
#filename:Nginx_start.sh
#date:2015-12-23
#作者:linuxzkq
#Email:1729294227@qq.com
#version:v1.0
. /etc/init.d/functions
path=/application/nginx/sbin/nginx
pid=/application/nginx/logs/nginx.pid
process=`ps -ef|grep nginx|grep -v grep|wc -l`
#USAGE
function USAGE(){
echo "USAGE:$0 {start|stop|restart|reload|status}"
exit 0
}
#start
function start(){
$path &>/dev/null
if [ $? -eq 0 ];then
action "Nginx is started:" /bin/true
else
action "Nginx is started:" /bin/false
fi
}
#stop
function stop(){
if [ $process -ne 0 ] && [ -s "$pid" ];then
killall nginx
action "Nginx is stopped:" /bin/true
else
action "Nginx is stopped:" /bin/false
fi
}
#reload
function reload(){
$path -s reload
}
#status
function status(){
if [ $process -ne 0 ] && [ -s "$pid" ];then
echo "Nginx is running."
else
echo "No Nginx Process!"
fi
}
#restart
function restart(){
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
reload)
reload
;;
*)
echo "Error,Please use an USAGE!"
USAGE
;;
esac
本文出自 “兰州linux运维” 博客,请务必保留此出处http://linuxzkq.blog.51cto.com/9379412/1727617
#filename:Nginx_start.sh
#date:2015-12-23
#作者:linuxzkq
#Email:1729294227@qq.com
#version:v1.0
. /etc/init.d/functions
path=/application/nginx/sbin/nginx
pid=/application/nginx/logs/nginx.pid
process=`ps -ef|grep nginx|grep -v grep|wc -l`
#USAGE
function USAGE(){
echo "USAGE:$0 {start|stop|restart|reload|status}"
exit 0
}
#start
function start(){
$path &>/dev/null
if [ $? -eq 0 ];then
action "Nginx is started:" /bin/true
else
action "Nginx is started:" /bin/false
fi
}
#stop
function stop(){
if [ $process -ne 0 ] && [ -s "$pid" ];then
killall nginx
action "Nginx is stopped:" /bin/true
else
action "Nginx is stopped:" /bin/false
fi
}
#reload
function reload(){
$path -s reload
}
#status
function status(){
if [ $process -ne 0 ] && [ -s "$pid" ];then
echo "Nginx is running."
else
echo "No Nginx Process!"
fi
}
#restart
function restart(){
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
reload)
reload
;;
*)
echo "Error,Please use an USAGE!"
USAGE
;;
esac
本文出自 “兰州linux运维” 博客,请务必保留此出处http://linuxzkq.blog.51cto.com/9379412/1727617
相关文章推荐
- nginx配置优化
- 轻松使用Nginx搭建web服务器
- nginx 多站点配置方法集合
- nginx配置
- nginx扩展模块,不能正常显示FastDfs上传的图片问题
- FastDFS的配置、部署与API使用解读(7)Nginx的FastDFS模块
- 使用 Nginx 提升网站访问速度
- 环境安装备忘录 Nginx
- nginx 监控ngtop
- nginx主要配置
- ubuntu14.04下nginx+gunicorn部署django1.8
- lamp+nginx代理+discuz+wordpress+phpmyadmin搭建二
- nginx 外网代理
- ubuntu 15.10 nginx rtmp 搭建
- linux下重启nginx的方法
- nginx优化之--慢连接攻击应…
- apache nginx mod_php、FastCGI、PHP-FPM
- Elasticsearch结合Nginx使用
- nginx 压缩和缓存设置
- Linux+Nginx+MySQL下配置论坛程序Discuz的基本教程