|
Answer» Hi !
This is my FIRST message in this forum. Good day to all.
I want to monitor a file. When the file changes, I want to be informed. There are folder watching programs for this, but I should write my own. I want a batch file to check a file PERIODICALLY. In case of any changes, I want it to trigger a command. For example opening the changed LOG.TXT file.
I did it with the following batch file. FC.EXE is a file of XP. It compares and finds out the differences between two files. And there is SLEEP.EXE from old dos versions.
This batch file does the following : 1 - Compares two files. When there is a difference, it opens the changed file. 2 - When the user reads and closes the log.txt file, sleep.exe waits 120 seconds 3 - 1 and 2 repeats.
@echo off :START FC c:\log.txt e:\log.txt IF ERRORLEVEL 1 goto DIFFERENT GOTO END :DIFFERENT e:\log.txt :END sleep 120 goto START
The only problem is that : the CPU usage is 100 % when the sleep command runs.
Is there a way, to make a batch file wait for a while and then run again without making the CPU %100 busy.
If I knew Visual Basic coding, It would be easy to do this.
Thank you all for your help,
OsmanYou could try:
Code: [Select]ping -n 121 localhost >NUL If 121 doesn't give a reasonable time you could try tweaking it a bit.Dear DeltaSlaya,
Thank you very much. You've solved my problem. That's what I want.
OsmanNo problem!
Thats a common way to resolve such an issue without USING additional files, and as I'm aware it doesn't use any considerable amount of CPU time.
If you have any other batch file queries don't hesitate to ASK on this forum again.
|