shell脚本检查网站是否正常

linux系统运维过程中,经常会遇到些问题,有时候问题会比较麻烦,此时shell脚本的优势就体现出来,下面我来介绍几种查看网站是否正常的shell脚本

shell脚本检查网站是否正常shell脚本检查网站是否正常

其一

#!/bin/bash
function usage(){
echo $"usage:$0 url"
exit 1
}

function check_url() {

wget --spider -q -o /dev/null --tries=1 -T 5 $1
if [ $? -eq 0 ]
then
echo "$1 is yes."
exit 0
else
echo "$1 is fail."
exit 1
fi
}

其二

#!/bin/bash
. /etc/init.d/functions
num=`curl -I -m 5 -s -w "%{http_code}\n" -o /dev/null 192.168.100.141:8080`
if [ $num -eq 200 ]
then action "ok!" /bin/true
else action "failure" /bin/false
fi

其三

. /etc/init.d/functions
curl -s -o /dev/null 192.168.100.141:8080
if [ $? -eq 0 ]
then action "Web site access is normal" /bin/true
else action "Failure of website access" /bin/false
fi

其四

#!/bin/bash
. /etc/init.d/functions
wget --spider -T 5 -q -t 2 192.168.100.141:8080

if [ $? -eq 0 ]
then action "Web site access is normal" /bin/true
else action "Failure of website access" /bin/false
fi

本文原创地址:https://www.linuxprobe.com/shell-web.html

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值