#!/bin/bash
#*/3 * * * * /usr/local/sbin/restart_php.sh > /dev/null 2>&1
url="http://xxx/php/php-fpm.php"
PROG=/usr/local/webserver/php/sbin/php-fpm
LOG=/tmp/php-cgi.log
maillist="xxx@qq.com"
time=`date`
status=$(curl -s --head "$url" | awk '/HTTP/ {print $2}')
if [ "$status" != "200" ]; then
echo "Restart php-cgi at ${time} " >> $LOG
$PROG restart
echo "HTTP stauts: ${status} time:$time" | /bin/mail -s "HTTP [restart_php] status check" ${maillist}fi
PHP执行文件
<?php
echo 1;
?>