Computing.Net > Forums > Programming > Monitor Log file useing DOC BATCH

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Monitor Log file useing DOC BATCH

Reply to Message Icon

Name: vishuonly4u
Date: May 4, 2008 at 23:47:20 Pacific
OS: DOS
CPU/Ram: 2
Product: 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.



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: May 5, 2008 at 02:38:11 Pacific
Reply:

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)


0

Response Number 2
Name: Mechanix2Go
Date: May 5, 2008 at 06:15:37 Pacific
Reply:

You COULD do it in DOS:

::==
@echo off

if not exist # goto :firstrun
fc log # > nul
if errorlevel 1 echo it's been changed
:firstrun
copy /b log # > nul


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 3
Name: klint
Date: May 5, 2008 at 13:06:38 Pacific
Reply:

If you just want to know if a service is running, why not use the actual command that tells you if a service is running?

NET START


0

Response Number 4
Name: vishuonly4u
Date: May 5, 2008 at 22:10:47 Pacific
Reply:

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.

could you pls help me in this.


0

Response Number 5
Name: Mechanix2Go
Date: May 5, 2008 at 23:52:31 Pacific
Reply:

You can nevermind the /TW; it's the default.


=====================================
If at first you don't succeed, you're about average.

M2


0

Related Posts

See More



Response Number 6
Name: vishuonly4u
Date: May 6, 2008 at 00:20:21 Pacific
Reply:

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.


0

Response Number 7
Name: Mechanix2Go
Date: May 6, 2008 at 04:08:16 Pacific
Reply:

I think klint said it: use the right tool.


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 8
Name: klint
Date: May 6, 2008 at 04:14:01 Pacific
Reply:

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.


0

Response Number 9
Name: Mechanix2Go
Date: May 6, 2008 at 04:49:11 Pacific
Reply:

picky, picky, picky

Here's one; no admin, no files

::==
@echo off

for /f "tokens=* delims= " %%a in ('dir/b log') do (
set new=%%~Ta
)

if "%old%" neq "%new%" echo changed

set old=%new%


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 10
Name: vishuonly4u
Date: May 6, 2008 at 23:01:55 Pacific
Reply:

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.


0

Response Number 11
Name: klint
Date: May 7, 2008 at 07:06:48 Pacific
Reply:

From my testing, ~T returns the file modification time, just as you require.


0

Response Number 12
Name: Mechanix2Go
Date: May 8, 2008 at 03:17:11 Pacific
Reply:

LOL Regardless of what anyone 'thinks' it shows last modified date/time.

Try it.


=====================================
If at first you don't succeed, you're about average.

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Monitor Log file useing DOC BATCH

backing up log files using vbscript www.computing.net/answers/programming/backing-up-log-files-using-vbscript/9220.html

Editing a Hex file using a Batch script www.computing.net/answers/programming/editing-a-hex-file-using-a-batch-script/19381.html

Log Files www.computing.net/answers/programming/log-files/14089.html