脚本之家,脚本语言编程技术及教程分享平台!
分类导航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|shell|

服务器之家 - 脚本之家 - shell - 检测网站down掉后自动发信的shell脚本代码

检测网站down掉后自动发信的shell脚本代码

2022-12-15 11:25shell教程网 shell

脚本用途:检测指定文件中的网站url,当一个网站down掉后,自动给指定的邮箱发信

复制代码 代码如下:


#!/bin/bash
#website test scripts
while true;do
        for cycle_temp in `cat url_list`
        do
                if  lynx -dump `echo ${cycle_temp}` -accept_all_cookies|grep "true";then
                        echo "The website is running naturally"

                else
                        echo "${cycle_temp} has been offline please attend it now!">/opt/test.txt
                        mail -v -s "website down mail" reterry123@163.com < /opt/test.txt
                fi
        done
        sleep 2s
done

延伸 · 阅读

精彩推荐