1. 程式人生 > 其它 >windows下指令碼每分鐘自動檢測Tomcat是否正常執行

windows下指令碼每分鐘自動檢測Tomcat是否正常執行

技術標籤:工具tomcatwindows

@echo on
:aa
set a=" "
for /f "tokens=5" %%i in ('netstat -aon ^| findstr "\<0.0.0.0:80\>"') do (
set a=%%i
)

set b=" "
for /f "tokens=1" %%i in ('tasklist ^| findstr "%a%"') do (
set b=%%i
)


if "java.exe"=="%b%" goto cc else goto bb

:bb
C:
CD "C:\BeX5_V3.4-ent\apache-tomcat\bin"
start /b startup.bat
ping 127.1 -n 60 >nul 2>nul
goto aa

:cc
ping 127.1 -n 60 >nul 2>nul
goto aa

如果需要自我適配需修改兩個地方
1.<0.0.0.0:80> : 80是埠號,修改為自己Tomcat埠號
1.CD “C:\BeX5_V3.4-ent\apache-tomcat\bin” : Tomcat的絕對路徑需要修改為自己的