#!/bin/bash export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin URL_LIST=$1 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 | egrep -o "200|301|302|" | wc -l) if [ $HTTP_CODE -eq 1 ]; 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