shell脚本3、检测网站地址是否存活
2019-02-13 本文已影响21人
iXiAo9
#!/bin/bash
. /etc/init.d/functions
url_list=(www.tec.com www.stu.com)
function chkurl(){
i=0
while [ $i -lt 2 ]
do
curl http://${url_list[$i]} &>/dev/null
if [ $? -eq 0 ]
then
action "${url_list[$i]}" /bin/true
else
action "${url_list[$i]}" /bin/false
fi
let i++
done
}
function main(){
while true
do chkurl
sleep 3
done
}
main