Solved Windows Script to Find String in Log File

June 8, 2012 at 01:40:17
Specs: Windows Server 2008 R2
I have IBM Cognos TM1 application running as Services on Windows Server 2008. When I start the Service, TM1 will write a log file named "tm1server.log" on "D:\TM1\log\". TM1 will continuously write this log until the service is ready, which normally takes 3 hours until the service is ready. When the service is ready, TM1 will write "TM1 Server is ready" on the log.

I want to make a script that continuously check the log file until the string "TM1 Server is ready" is written. When the string found, I want the script to run another script that will send email to me. I have made the script for sending email.

Can anybody help me?

Thanks and regards,


See More: Windows Script to Find String in Log File

Report •

June 8, 2012 at 02:05:27
✔ Best Answer
This may crash with two processes accessing the same file.

:: ===== script starts here ===============
:: monitor log for "TM1 Server is ready"
:: chrislog.bat Fri 08-06-2012 15:55:53.42
@echo off & setLocal enableDELAYedeXpansioN

find "TM1 Server is ready" < log > nul
if not errorlevel 1 goto :done
ping -n 1 -w 600000 > nul
goto :loop

:: run your mail thingy here

goto :eof

::====== script ends here =================

Life is too important to be taken seriously.


Report •

June 8, 2012 at 02:37:40
tm1sd,exe accessing tm1server.log to write the log.. if the script is running, will there be problems for tm1sd.exe writing the log file?

Report •

Related Solutions

Ask Question