自动判断NGINX和php-cgi状态重启SHELL脚本

NGINX

  
  
  
  
  1. #!/bin/bash  
  2. #*/3 * * * * /data/shell/nginx.sh  > /dev/null 2>&1   
  3. url="http://xxx.xxx.com/nginx.html" 
  4. PROG=/usr/local/nginx/sbin/nginx  
  5. LOG=/root/nginx.log  
  6. maillist="[email protected]" 
  7. time=`date`  
  8. status=$(curl -s --head "$url" | awk '/HTTP/ {print $2}')  
  9. if [ "$status" != "200" ]; then 
  10.      echo "Restart nginx at ${time} " >> $LOG  
  11.      killall nginx  
  12.      $PROG  
  13.      echo "HTTP stauts: ${status} time:$time" | /bin/mail -s "HTTP [nginx80] status check" ${maillist}  
  14.        
  15. fi  

 

 

php-fpm

 

  
  
  
  
  1. #!/bin/bash  
  2. #*/3 * * * * /usr/local/sbin/restart_php.sh  > /dev/null 2>&1   
  3. url="http://www.xxx.com/php-fpm.php" 
  4. PROG=/usr/local/php5.2.17/sbin/php-fpm  
  5. LOG=/tmp/php-cgi.log  
  6. maillist="[email protected]" 
  7. time=`date`  
  8. status=$(curl -s --head "$url" | awk '/HTTP/ {print $2}')  
  9. if [ "$status" != "200" ]; then 
  10.      echo "Restart php-cgi at ${time} " >> $LOG  
  11.      $PROG restart  
  12.      echo "HTTP stauts: ${status} time:$time" | /bin/mail -s "HTTP [restart_php] status check" ${maillist}  
  13.        
  14. fi 

 

 

 

 

你可能感兴趣的:(nginx,休闲,php-cgi,重启脚本,判断NGINX)