1、URL检测脚本
[[email protected] scripts]# vi check_url.sh [[email protected] scripts]# cat check_url.sh #!/bin/sh . /etc/init.d/functions 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 action "$1 is yes." /bin/true else action "$1 is no." /bin/false fi } function main(){ if [ $# -ne 1 ] then usage fi check_url $1 } main $*
2、测试脚本
[[email protected] scripts]# sh check_url www.baidu.com www.baidu.com is yes. [ OK ] [[email protected] scripts]# sh check_url www.12424kjlkjsdfliuwrt.com www.12424kjlkjsdfliuwrt.com is no. [FAILED]
3、自已可以设置crontab和报警邮箱
时间: 2024-11-10 08:35:06