Name: vishuonly4u Date: May 4, 2008 at 23:47:20 Pacific Subject: Monitor Log file useing DOC BATCH OS: DOS CPU/Ram: 2 Model/Manufacturer: 2
Comment:
Team, I want to monitor a log file of a service. If service is running normal then this get update in every 15min. So I want to monitor if the log file is getting updated in every 15min or not. If its not updating then it means service is not running. and hence it must send some echo statement. Could you please help me on this? I tried " %~tI - expands %I to date/time of file" but this returns the file creation time. So please suggest me if we have any other way out for this.
First of all your operating system is not DOS as you are talking about services and variable modifiers, I suppose you are running a NT based environment like XP or 2000 where there is no DOS at all.
About your problem you have to parse the output of Dir command with the /TW switch that takes into account the most recent access to write the file. Something as
for /F "tokens=2" %%a in ('dir /TW log.txt') do ( echo Log.txt updated at %%~b)
thanks.. i think dir /tw option will work.. and i must say .. I dont have full access on the server due to IS rules. So I can just monitor log files in order to monitor the service is running or not. I am planing to use /tw option with a find command. I will pass todays date and current hour from date/t and time/t command. will try to search this pattern in find command.
I want to find this without saving out put of dir to any file. without creating any few temp file i want to find out this. could u pls suggest me some solution.
M2, as I understand it vishu can't use my suggestion because it requires Administrator privilege. On the other hand, he can see the file the service creates, even without Administrator privilege, so he can see whether the service is running or not using this indirect method.
To avoid creating a temporary file, he will have to keep the last checked file timestamp in an environment variable. That's a bit tricky for me right now.
M2... thanks a lot. But I think we cant use %%~T option as it returns only file creation date. so to understand the file modification date i think we have to use some option form DIR command. But i really dont understand how it will work without creating a a temp file.
The information on Computing.Net is the opinions of its users. Such
opinions may not be accurate and they are to be used at your own risk.
Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE