方法1:
wget参数 : --spider 模拟爬虫访问网站 -q 安静的访问不输出 -T 访问网站超时时间 -t 当网站异常时重试网站的次数
例:[root@localhost ~]# wget --spider -T 5 -q -t 2 www.keysou.com[root@localhost ~]# echo $? #使用返回值确定网站是否正常0
[root@localhost ~]# vim wget_url.sh############################################################## File Name: wget_url.sh# Author: 萧萧一风# E-mail: 77368447.com# Created Time: Fri Aug 9 20:47:50 CST 2019#==================================================================#!/bin/bashwget --spider -q -T 5 -t 2 $1if [ $? = 0 ];thenecho "$1 访问OK!!!"#此处可写邮件发送管理员elseecho "$1 访问失败,请检查!!"#此处可写邮件发送管理员fi
方法2:
curl参数: -s 静默访问 -o 记录访问信息到文件中
例:[root@localhost ~]# curl -s -o /dev/null keysou.com [root@localhost ~]# echo $? #使用返回值确定网站是否正常0
[root@localhost ~]# vim curl_url.sh############################################################## File Name: vim curl_url.sh# Author: 萧萧一风# E-mail: 77368447.com# Created Time: Fri Aug 9 20:47:50 CST 2019#==================================================================#!/bin/bashcurl -o /dev/null -s $1if [ $? = 0 ];thenecho "$1 访问OK!!!"#此处可写邮件发送管理员elseecho "$1 访问失败,请检查!!"#此处可写邮件发送管理员fi
发表评论