windows下指令碼每分鐘自動檢測Tomcat是否正常執行
阿新 • • 發佈:2021-02-06
@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的絕對路徑需要修改為自己的