NGINX
- #!/bin/bash
- #*/3 * * * * /data/shell/nginx.sh > /dev/null 2>&1
- url="http://xxx.xxx.com/nginx.html"
- PROG=/usr/local/nginx/sbin/nginx
- LOG=/root/nginx.log
- maillist="xxx@xxx.com"
- time=`date`
- status=$(curl -s --head "$url" | awk '/HTTP/ {print $2}')
- if [ "$status" != "200" ]; then
- echo "Restart nginx at ${time} " >> $LOG
- killall nginx
- $PROG
- echo "HTTP stauts: ${status} time:$time" | /bin/mail -s "HTTP [nginx80] status check" ${maillist}
- fi
php-fpm
- #!/bin/bash
- #*/3 * * * * /usr/local/sbin/restart_php.sh > /dev/null 2>&1
- url="http://www.xxx.com/php-fpm.php"
- PROG=/usr/local/php5.2.17/sbin/php-fpm
- LOG=/tmp/php-cgi.log
- maillist="xxx@xxx.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
转载于:https://blog.51cto.com/ppabc/785745