shell脚本简单检测网站是否存活!

检测网站是否存活!
编写一个url.txt文件(公司域名)
shell脚本简单检测网站是否存活!
shell脚本简单检测网站是否存活!
使用curl 命令 判断 访问网站的状态码(200为ok)
#vim url.sh
#!/bin/bash
check(){
code=curl -I -m 10 -o /dev/null -s -w %{http_code} http://${url} (curl 命令)
if [ $code -eq 200 ];then (if 判断)
echo “ok”
echo “你好” | mail -s “test” 13427****@qq.com
else
echo “no”
echo “网站错误” | mail -s “test” 13427****@qq.com
fi
}
#EOF只是一个分界符
:<<EOF
for curl in cat curl.txt
do
check
done
EOF
while read curl
do
check
done < curl.txt
运行脚本
shell脚本简单检测网站是否存活!
shell脚本简单检测网站是否存活!