Chinaunix首页 | 论坛 | 博客
  • 博客访问: 573372
  • 博文数量: 111
  • 博客积分: 3478
  • 博客等级: 中校
  • 技术积分: 1327
  • 用 户 组: 普通用户
  • 注册时间: 2009-05-28 22:37
文章分类

全部博文(111)

文章存档

2013年(4)

2012年(57)

2011年(15)

2010年(7)

2009年(28)

分类: LINUX

2012-03-15 13:17:51

#!/bin/bash
# chkconfig: 345 85 15
# description: nginx is a web cache server
# processname: nginx
. /etc/rc.d/init.d/functions
case $1 in
"start") /usr/local/nginx/sbin/nginx
if [ $? == "0" ];then
echo "nginx start ok"
else
echo "please check the log"
fi
;;
"stop") /usr/local/nginx/sbin/nginx -s stop
if [ $? == "0" ];then
echo "nginx stop ok"
else
echo "please check the log"
fi
;;
"restart")
/usr/local/nginx/sbin/nginx -s reload
if [ $? == "0" ];then
 echo "nginx restart ok" 
else
echo "nginx restart failed"
fi
;;
 
"status")
proces_number=`ps -fe | grep -i nginx | grep -iv grep | wc -l`
if [ "$proces_number" -gt 3 ];then
echo "nginx runs ok"
else
echo "nginx has problem,please check log"
fi
;;
*)
echo "Usage only start|stop|restart"
;;
esac
 
脚本的用法:
一.把脚本内容复制下来保存到一个文档内,文档名称改为nginx,
二.赋给脚本可执行权限,并把脚本放到/etc/init.d/目录下
三.chkconfig --add nginx
然后就可以用service 来启动关闭重启查看nginx状态了
阅读(671) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~