shell批量监控网站状态码脚本,使用curl很慢。等我学完其他方式,在来更新。
#!/bin/bash #GuoYabin yuming=`/bin/cat yuming.txt` for i in $yuming do result=`/usr/bin/curl -I $i 2>/dev/null|awk '/HTTP/{print $2}'` res=$[result+1] #这个方法很烂,浮点数要过滤成整数。 res=`echo $res |awk -F '.' '{print $1}'` if [ $res -ge 400 ];then echo "$i is $result " | mail -s "http_server" guoyabin@ccln.gov.cn else if [ $res -eq 1 ];then echo "$i resolve error" | mail -s "http_server" guoyabin@ccln.gov.cn fi fi done