Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Subject: Monitor Log file useing DOC BATCH

Original Message
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.

Report Offensive Message For Removal

Response Number 1
Name: IVO
Date: May 5, 2008 at 02:38:11 Pacific
Subject: Monitor Log file useing DOC BATCH
Reply: (edit)
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)


Report Offensive Follow Up For Removal

Response Number 2
Name: Mechanix2Go
Date: May 5, 2008 at 06:15:37 Pacific
Subject: Monitor Log file useing DOC BATCH
Reply: (edit)
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


Report Offensive Follow Up For Removal

Response Number 3
Name: klint
Date: May 5, 2008 at 13:06:38 Pacific
Subject: Monitor Log file useing DOC BATCH
Reply: (edit)
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


Report Offensive Follow Up For Removal

Response Number 4
Name: vishuonly4u
Date: May 5, 2008 at 22:10:47 Pacific
Subject: Monitor Log file useing DOC BATCH
Reply: (edit)
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.


Report Offensive Follow Up For Removal

Response Number 5
Name: Mechanix2Go
Date: May 5, 2008 at 23:52:31 Pacific
Subject: Monitor Log file useing DOC BATCH
Reply: (edit)
You can nevermind the /TW; it's the default.


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

M2


Report Offensive Follow Up For Removal

Response Number 6
Name: vishuonly4u
Date: May 6, 2008 at 00:20:21 Pacific
Subject: Monitor Log file useing DOC BATCH
Reply: (edit)
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.

Report Offensive Follow Up For Removal

Response Number 7
Name: Mechanix2Go
Date: May 6, 2008 at 04:08:16 Pacific
Subject: Monitor Log file useing DOC BATCH
Reply: (edit)
I think klint said it: use the right tool.


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

M2


Report Offensive Follow Up For Removal

Response Number 8
Name: klint
Date: May 6, 2008 at 04:14:01 Pacific
Subject: Monitor Log file useing DOC BATCH
Reply: (edit)
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.


Report Offensive Follow Up For Removal

Response Number 9
Name: Mechanix2Go
Date: May 6, 2008 at 04:49:11 Pacific
Subject: Monitor Log file useing DOC BATCH
Reply: (edit)
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


Report Offensive Follow Up For Removal

Response Number 10
Name: vishuonly4u
Date: May 6, 2008 at 23:01:55 Pacific
Subject: Monitor Log file useing DOC BATCH
Reply: (edit)
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.

Report Offensive Follow Up For Removal

Response Number 11
Name: klint
Date: May 7, 2008 at 07:06:48 Pacific
Subject: Monitor Log file useing DOC BATCH
Reply: (edit)
From my testing, ~T returns the file modification time, just as you require.

Report Offensive Follow Up For Removal

Response Number 12
Name: Mechanix2Go
Date: May 8, 2008 at 03:17:11 Pacific
Subject: Monitor Log file useing DOC BATCH
Reply: (edit)
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


Report Offensive Follow Up For Removal



Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Monitor Log file useing DOC BATCH 

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software



Version Tracker Pro
Keep your software current and secure, effortlessly

Click Here for a Free Scan

Driver Agent
Automatically find the latest drivers for your computer.
Click Here for a Free Scan



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

All content ©1996-2007 Computing.Net, LLC