가끔씩 windows 서버를 다룰 때가 있다.
이럴 경우 WAS 와 같은 경우 문제가 생기면 자동으로 kill 하고 Alarm 처리 후 다시 restart 하는 일련의 script 들이
Linux의 경우는 샘플로 제법있는데, windows 서버는 참으로 찾기 힘들다.
그런데, windows 창 이름을 가지고 process id를 찾아서 kill 하는 방법이 stackoverflow에 있길래 우선 정리해본다.
(고마운 stackoverflow ^^)
아직 테스트는 안해봤지만, 제법 유용할듯하다.
====================================================================
Start multiple processes in parallel:
start "<window title>" <command will be executed>
Example:
start "service1" mvn clean spring-boot:run
start "service2" mvn clean spring-boot:run
Obtain the PID of the processes (optional):
tasklist /V /FI "WindowTitle eq service1*"
tasklist /V /FI "WindowTitle eq service2*"
Kill the processes:
taskkill /FI "WindowTitle eq service1*" /T /F
taskkill /FI "WindowTitle eq service2*" /T /F
====================================================================