boat73 has asked for the wisdom of the Perl Monks concerning the following question:

Greetings wise ones. I am trying to write a script which will take action on every line written to a log on a Win32 system. File::Tail does exactly what I need except when the log reaches it's max size setting and start top filling. At that point the script just sits and wats for a nerw entry at the bnottom that never comes. Here is a snippeet of my code, but I am open to any suggestions including another module. Thanks in advance for the help.
use File::Tail; use HTTP::Date; use DBI; $name = "c:\\temp\\test.log"; $file=File::Tail->new(name=>$name, interval=>1, maxinterval=>10, tail= +>100); while (defined($line=$file->read)) { print "$line\n"; }

Replies are listed 'Best First'.
Re: File::Tail with top fill logs
by blazar (Canon) on Oct 12, 2006 at 14:39 UTC
    File::Tail does exactly what I need except when the log reaches it's max size setting and start top filling.

    What is "it's max size"? I guess you're not filling the filesystem. I guess that you have some program that writes to the log and when it has reached some critical size either in bytes or lines or whatever, starts writing into it from the beginning. It would be interesting to know if it just rewinds it (as with Perl's seek) or if it closes it and opens it again. Without knowing, you may try monitoring the file for size changes or access time modification or something like that.

      Good suggestions, but when the file reaches it's max size inm bytes the file mod time does not change nor does the size. It does create a backup and I can scan that every time it's modtime changes, but I was hoping for something more realtime.
        Hmmm. I'm chasing the same problem, I think. Are you working on Windows Schedlgu.txt (task scheduler) log file?
          I'm considering a few options
        1. Brute force solution -- delete the file after each check. If I need to keep the data, write it off to another file.
        2. The lazy admin solution -- Have Windows notify you when Task Scheduler can't run a task. See http://support.microsoft.com/kb/308558. Of course, this requires faith that Windows will actually do what it says it will.
        3. The whole thing solution -- check the whole file for failure s each time. One of the end users I'm supporting suggested this.
        4. Time and date solution. Look for the appropriate time and date a task should run and get the matching log entry.
        5. Perl Watchmaker's solution. Use Win32::TaskScheduler. Very fine-grained control. Do you need that much?