shell 脚本检测网站存活

shell 脚本检测网站存活

#!/bin/bash
. /etc/init.d/functions

check_fun(){
url_list=(www.baidu.com www.youku.com www.tudou.com www.xxxxxx55555555555555555555555xxxxxxxxxx.com)
for i in ${url_list[@]}
do
#echo i c u r l − s − o / d e v / n u l l h t t p : / / i curl -s -o /dev/null http:// icurlso/dev/nullhttp://i
if [ KaTeX parse error: Expected 'EOF', got '#' at position 29: …en #̲echo "i is ok"
action “KaTeX parse error: Expected 'EOF', got '#' at position 35: …se #̲echo "i not ok”
action “$i” /bin/false
fi

done
}
while :
do
check_fun
sleep 3
done

[root@master ~]# cat check_url_2.sh
#!/bin/bash
. /etc/init.d/functions

check_fun(){
#url_list=(www.baidu.com www.youku.com www.tudou.com www.xxxxxx55555555555555555555555xxxxxxxxxx.com)
#for i in ${url_list[@]}
while read i
do
#echo i c u r l − s − o / d e v / n u l l h t t p : / / i curl -s -o /dev/null http:// icurlso/dev/nullhttp://i
if [ KaTeX parse error: Expected 'EOF', got '#' at position 29: …en #̲echo "i is ok"
action “KaTeX parse error: Expected 'EOF', got '#' at position 35: …se #̲echo "i not ok”
action “$i” /bin/false
fi

done < /tmp/url.txt
}
while :
do
check_fun
sleep 3
done

curl -I -m 10 -o /dev/null -s -w %{http_code} www.baidu.com
-I 仅测试HTTP头
-m 10 最多查询10s
-o /dev/null 屏蔽原有输出信息
-s silent 模式,不输出任何东西
-w %{http_code} 控制额外输出

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值