1、URL检测脚本
[root@sxun scripts]# vi check_url.sh
[root@sxun 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、测试脚本
[root@sxun scripts]# sh check_url www.baidu.com www.baidu.com is yes. [ OK ] [root@sxun scripts]# sh check_url www.12424kjlkjsdfliuwrt.com www.12424kjlkjsdfliuwrt.com is no. [FAILED]
3、自已可以设置crontab和报警邮箱
本文出自 “福州恒达电脑” 博客,请务必保留此出处http://fzhddn.blog.51cto.com/12650899/1945011
原文:http://fzhddn.blog.51cto.com/12650899/1945011