根據windows守護tomcat的bat批處理腳本加強功能
原理:發現webapps目錄下有新的ROOT.war包進行解壓替換,重啓tomcatweb
@echo off setlocal enabledelayedexpansion set TOMCAT_HOME=C:\utils\apache-tomcat-7.0.65 set TOMCAT_PORT=8080 :RESTART cd %TOMCAT_HOME%\webapps if exist ROOT.war ( move /y ROOT.war ROOT cd ROOT start /wait "" "C:\Program Files\WinRAR\WinRAR.exe" x -y ROOT.war for /f "delims= tokens=1" %%i in ('netstat -aon ^| findstr "%TOMCAT_PORT%"') do ( set a=%%i taskkill /pid "!a:~71,5!" ) ) cd /d %~dp0 netstat -an | find /C "0.0.0.0:%TOMCAT_PORT%" > temp.txt set /p num=<temp.txt del /F temp.txt if %num%==0 ( start /D "%TOMCAT_HOME%\bin\" startup.bat ) cd /d %~dp0 echo Wscript.Sleep WScript.Arguments(0) >sleep.vbs cscript //b //nologo sleep.vbs 5000 goto RESTART