Windows下监听tomcat并重启

日期:2011-12-09    阅读:51   分类:综合信息

方法一:监测工具,比如“tomcat自启动监测平台”

方法二:如下的vbs脚本   保存为vbs文件 双击执行。循环时间可改。

说明:1.txt是重启记录,并且tomcat已安装成服务,安装方法是进入tomcat的bin目录,执行service install即可,对应的服务名为tomcat6,以版本而定。

On   Error   Resume  Next
Set WshShell = WScript.CreateObject("WScript.Shell")
set fs = createobject("scripting.filesystemobject")
    
Do While True     
    Set http = CreateObject("Microsoft.XMLHTTP")     
    http.open "GET","http://localhost:8000/",false
    http.send

    if http.Status >  299 then   
        set ts =fs.opentextfile("c:\1.txt",8,true)

        WshShell.Run("net   stop   Tomcat6")
        WScript.Sleep(10000)     
        WshShell.Run("net   start   Tomcat6")

        ts.write "tomcat was started."
        ts.write "error code:"
        ts.write http.Status
        ts.write "-------error time:"
        ts.write now
        ts.writeblanklines 2
        ts.close

    end if     
    WScript.Sleep(30000)
loop

最后至于开机启动:
1、window任务计划。
2、系统服务自动启动方式。

本页链接: http://www.scriptlover.com/static/1309-windows-tomcat

标签:

相关文章

网友评论

Leave a comment

 required

 required (Not published)

 required