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

小编给大家分享一下如何实现检测网站down掉后自动发信的shell脚本代码,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!

代码如下:

#!/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

看完了这篇文章,相信你对“如何实现检测网站down掉后自动发信的shell脚本代码”有了一定的了解,如果想了解更多相关知识,欢迎关注行业资讯频道,感谢各位的阅读!