重启nginx
Nginx 502 Bad Gateway 自动重启shell脚本
星期三, 八月 14th, 2013 | JAVA-and-J2EE, linux, php | 2 Comments
Nginx 502 Bad Gateway 自动重启shell脚本,启动 php 和重启nginx
新建 php文件 200_ok.php 文件(这个随便,内容也随便只要是想使用curl的访问方式)
<?php echo "200"; ?> |
建立一个脚本 vi web_monitor.sh (里面还有重启tomcate 的指令,后来发现使用正常关闭shutdown 有文件后台进程相关,可以直接杀掉进程的方式 ps -ef|grep java)
内容如下:
#!/bin/bash
#author:Pomelo Lee
#website://b.xuekewen.com
CheckUrl="//b.xuekewen.com/200_ok.php"
STATUS_CODE=`curl -o /dev/null -m 10 --connect-timeout 10 -s -w %{http_code} $CheckUrl`
#echo "$CheckURL Status Code:\t$STATUS_CODE"
if [ "$STATUS_CODE" != "200" ]; then
/usr/local/webserver/php/sbin/php-fpm stop
sleep 1
/usr/local/webserver/php/sbin/php-fpm start
sleep 1
pkill -9 nginx
sleep 1
/usr/local/webserver/nginx/sbin/nginx
#sleep 1
#/usr/local/tomcat7/bin/shutdown.sh
#sleep 2
#/usr/local/tomcat7/bin/startup.sh
fi |
然后是设定权限:chmod 755 /root/web_monitor.sh
运行定时程序:crontab -e
输入以下内容每隔5分钟检测一次:*/5 * * * * /root/web_monitor.sh
Search
相关文章
热门文章
最新文章
文章分类
- ajax (10)
- algorithm-learn (3)
- Android (6)
- as (3)
- computer (86)
- Database (30)
- disucz (4)
- enterprise (1)
- erlang (2)
- flash (5)
- golang (3)
- html5 (18)
- ios (4)
- JAVA-and-J2EE (186)
- linux (144)
- mac (10)
- movie-music (11)
- pagemaker (36)
- php (50)
- spring-boot (2)
- Synology群晖 (2)
- Uncategorized (7)
- unity (1)
- webgame (15)
- wordpress (33)
- work-other (2)
- 低代码 (1)
- 体味生活 (40)
- 前端 (21)
- 大数据 (8)
- 游戏开发 (9)
- 爱上海 (19)
- 读书 (4)
- 软件 (3)
