批量检测网站是否异常脚本sh

#!/bin/bash  
URL_LIST="www.baidu.com www.ctnrs.com"
for URL in $URL_LIST; do
   FAIL_COUNT=0
   for ((i=1;i<=3;i++)); do
       HTTP_CODE=$(curl -o /dev/null --connect-timeout 3 -s -w "%{http_code}" $URL)
       if [ $HTTP_CODE -eq 200 ]; then
           echo "$URL OK"
           break
       else
           echo "$URL retry $FAIL_COUNT"
           let FAIL_COUNT++
       fi
   done
   if [ $FAIL_COUNT -eq 3 ]; then
       echo "Warning: $URL Access failure!"
   fi
done


Powered By Z-BlogPHP 1.7.3

 Theme By 优美模版

本博客为开源博客,本博客联系QQ:372097243