Windows Batch Script 심오하군...
특정 Tomcat Instance 찾아 KILL
@echo off setlocal enableDelayedExpansion # Command 에서는... wmic process where "Name='java.exe' AND commandLine like '%test-app%'" delete # Batch Script 에서는 "%" 변수에대한 접두사라서 LIKE 검색이 안되니 두개로... 그 안에 변수라면 아래와 같이 wmic process where "Name='java.exe' AND commandLine like '%%%HTTPD_WORKER_NM%%%'" delete
Tomcat 기동여부 확인 - 해당 포트가 떠 있나 확인 후 있으면 PID 및 실행 문자열 출력
@echo off setlocal enableDelayedExpansion netstat -na | find "LISTENING" | find /C ":%AJP_PORT%" > tmpFile set /P result=<tmpFile del tmpFile REM echo !result! if !result!==0 ( echo ===== TOMCAT IS STOPED ===== ) else ( echo ===== TOMCAT IS RUNNING ===== wmic process where "Name='java.exe' AND commandLine like '%%%HTTPD_WORKER_NM%%%'" get commandLine, processid )