#!/bin/bash
##php连接数撑满,检查返回状态码非200来重启php
###by Shengwen.Wang
#curl=`curl -s http://1.1.1.1/auth/login --speed-time 5 --speed-limit 1`
#curl=`curl -s http://1.1.1.1/auth/login -I |awk ‘NR==1&&$2=200{print $2}‘`
curl=`curl -I -m 10 -o /dev/null -s -w %{http_code} http://1.1.1.1/auth/login`
while :; do
if [ $curl -ne 200 ]
then
#echo "error" ############这一行为了测试服务器上来验证这个脚本是否生效
systemctl restart php-fpm
else
ps aux |grep php-fpm |grep -v "grep" |wc -l > /tmp/phpliang.log
ps aux |grep nginx |grep -v "grep" |wc -l > /tmp/nginxliang.log
exit 0
fi
break
done
原文地址:http://blog.51cto.com/wsw26/2083345