shell检测网站地址是否存活

#!/bin/bash
. /etc/init.d/functions
url_list=(www.baidu.com)
ChkCurl(){
        i=0
        while [ $i -lt 2 ]
        do
                curl http://${url_list[$i]} &>/dev/null
                if [ $? -eq 0 ];then
                        action "${url_list[$i]}" /bin/ture
                else
                        action "${url_list[$i]}" /bin/false
                fi
                let i++

        done
}
main(){
while true
do
        ChkCurl
        sleep 3

done
}
main

  

猜你喜欢

转载自www.cnblogs.com/liushuqing/p/11608096.html