Howdy Monks,

I am trying to determine what might be a way to remember a location in a Log file if my FIFO process dies or is killed. Currently the code I have does maintain its location within a growing log, but if the process dies or is killed I lose my location. I was wondering if I write my tell() information to a file on each iteration, and then have the code read this information only upon a new startup of the process would it work? But what I am not sure of is how would I fall back into my loop using the seek() information. Or if anyone has a better way of maintaining a growing log. I have seen the File::Tail module, but am having trouble getting it to work. Anyway, here's my FIFO code. Thanks in advance.

# Preset Values my $LogFile="/usr/local/apache2/eventmgr/ncomount/page.log"; my $PipeName="/usr/local/apache2/pipes/.nco_p_data"; my $naptime=5; my $curpos; open(LOGFILE, "<$LogFile") || die "Couldn't open file $Status - $!\n" +; for(;;){ for($curpos=tell(LOGFILE);LOGFILE;$curpos=tell(LOGFILE)){ while($line=<LOGFILE>){ # print $line; if($line =~ /(.*)\|~\|(.*)\|~\|(.*)/){ $PagerID=$1; $Message=$2.$3; } unless( -p $PipeName) { unlink $PipeName; system("mkfifo -m 644 $PipeName") && die "Can' +t mkfifo $PipeName: $!"; } open(FIFO,">$PipeName") || die "Couldn't open +file $PipeName - $!\n"; print FIFO "NEW|TODAY|NOW|\"\"|$PagerID|$Messa +ge\n"; close(FIFO); } sleep(1); } sleep $naptime; seek(LOGFILE, $curpos, 0); # seek to where we had been }

In reply to Remembering Log Location after process dies. by onegative

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.