分享一个简单的URL检测脚本。

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_41772936/article/details/80820516
!/bin/bash
This is zhang yu an
2018-6-24
. /etc/init.d/functions
if [ $# == 0 ]
   then
        echo "请在后面输入您要检测的url,此脚本可帮您自动检测可用性"
exit 1
fi


wget --spider -q -o /dev/null --tries=1 -T 5 $1
if [ $? -eq 0 ]
   then
        action "$1 is ok!!!" /bin/true
   else
        action "$1 is error!!!" /bin/false
fi

=====================================================

!/bin/bash
This is zhang yu an
2018-6-24
. /etc/init.d/functions 加载函数后面要用到提示
if [ $# == 0 ]   如果什么都没输入提示用户输入url
   then
        echo "请在后面输入您要检测的url,此脚本可帮您自动检测可用性"
exit 1
fi

检测网站是否可用 --tries 重试次数 -T 连接失败超时时间  $1就是用户输入的url
-q 安静的  -o下载到指定位置
wget --spider -q -o /dev/null --tries=1 -T 5 $1
if [ $? -eq 0 ] 如果$?为0说明没问题
   then
        action "$1 is ok!!!" /bin/true   成功的提示
   else   否则
        action "$1 is error!!!" /bin/false   失败的提示
fi

测试结果

这里写图片描述

是不是很简单 ,拜拜。

猜你喜欢

转载自blog.csdn.net/qq_41772936/article/details/80820516