用wget实现网站监测功能

转载本站文章请注明,转载自:昕星谷[http://oneyicn.gobaiyi.com]
本文链接: 用wget实现网站监测功能">http://oneyicn.gobaiyi.com/archives/1276/

由于某种需要,想用批处理实现监测一个网站,如果能正常返回打开,就运行一定的功能,不能正常返问就运行另一种程序或做相应的处理,同时作好相应的日志记录只要用到wget.exe这个命令行程序就可以实现了。完整的批处理代码如下 :

@echo off
title 测试网站能否正常返问by http://www.gobaiyi.com之昕星谷
rem 测试网站能否正常返问by http://www.gobaiyi.com之昕星谷
rem url设置要临测的网站地址 logfile为要记录的日志文件
set url=http://www.gobaiyi.com
set logfile=weblog.txt
@echo off
wget  %url% -q --spider||goto 2
goto 1
 
:2
echo 网站 %url% 不能正常返问于 %date%%time% >>%logfile%
 
goto 3
 
:1
echo 网站 %url% 能正常返问于 %date%%time% >>%logfile%
 
goto 3
:3
 
exit
 
rem 测试网站能否正常返问by http://www.gobaiyi.com之昕星谷

注意下载好wget.exe文件放在批处理的同一个目录下,稍加改进可以做进循环跟延时等功能。

随机文章推荐

2010年1月31日 | 归档于 网站, 网络
本文目前尚无任何评论.

发表评论

XHTML: 您可以使用这些标签: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

无觅相关文章插件,快速提升流量