dirtdog:

Like armstd mentioned, part of the problem is that you're rewinding the file to the beginning. I'd suggest tracking the last line of the file you examined each time with a log tailing module (as described to by i5513) or something like this (untested):

sub saveFilePos { my ($fileno, $filename) = @_; my $filepos = tell($fileno); open my $FH, '>', $filename or die "Can't open $fname: $!"; print $FH $filepos; close $FH; } sub process { my $file = "/$ENV{HOME}/Error.log"; my $file_last = "/$ENV{HOME}/Error.log.lastpos"; my $file_pos = 0; # Default to beginning of file eval { # Get last position in file (if any) open my $FH, '<', $file_last; if ($FH) { $file_pos = <$FH>; close $FH; } open ($tail,"<",$file_name) or die "Can't open file $file_name +"; seek($tail, $file_pos, 0); for(;;) { for $line (<$tail>) { if ( /OutOfMemoryError/) { send_mail($_,$.); } } } # Save last position examined saveFilePos($tail, $file_last); close($tail); } }

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re: Find error message starting at line after last error by roboticus
in thread Find error message starting at line after last error by dirtdog

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.