hc.bat
set num=0
setlocal ENABLEDELAYEDEXPANSION
for /f "tokens=1-3 delims=;" %%a in (server.conf) do (
findstr /b "^#" %%a >nul 2>&1
if errorlevel 1 start /B check.bat %%a %%b %num% > check!num!.log
set /A num=num+1
)
)
endlocal
exit /b 2
check.bat
set svr=%1
set log=%2
set num=%3
echo %svr% %log% !num!
setlocal ENABLEDELAYEDEXPANSION
copy /y NUL output!num!.tmp >NUL
powershell -command "& {Get-Content %log% | Select-Object -last 1}">> output!num!.tmp
type output!num!.tmp | findstr /m "STUCK" >nul 2>&1
if %errorlevel%==0 (goto action)
type output!num!.tmp | findstr /m "shut" >nul 2>&1
if %errorlevel%==0 (goto action)
:action
type output!num!.tmp
del output!num!.tmp
exit /b 2
Two problems with the script 1) the process keeps holding to the log file check0.log 2) In the hc.bat, I'm trying to use the findstr to ignore lines that start with #, but it doesn't seem to be working