any form of the "follow" options (e.g., "tail -f", "tail --follow", etc.) it never gives anything

Hm. It's possible you have a newer version that is fundementally broken and nobody has noticed, but I seriously doubt it. It is more likely to be how you are using it. The following two scripts demonstrate that it works:

A simulated high speed, rotating logger:

#! perl -slw use strict; my $logname = 'theLog'; while( 1 ) { open LOG, '>', $logname or die $!; for( 1 .. 1000 ) { print LOG "Line $_ of the log with some superfluous extra text + as filler"; } close LOG; my $n = 0; $n++ while -e "$logname.$n"; rename $logname, "$logname.$n"; }

A tail -F script:

#! perl -sw use strict; my $pid = open LOG, "tail -F theLog |" or die $!; $SIG{ INT } = sub{ close LOG; kill 3, $pid; exit; }; $SIG{ BREAK } = $SIG{ INT }; while( <LOG> ) { print; }
the tail.exe process needs to be maually killed.

Methinks you have unreal expectations. Any version of tail on any platform when used with -F (--follow=name) will have to be explicitly terminated, whether manually or programmically, by some external influence. It could not be any other way.

When following a rotating named file, there will always be a short but real period between the renaming of the old log and the creation of the new one. Sp tail has to be written to ignore any 'file not found' errors from open and retry. There is therefore, no reasonable condition for it to self terminate.

So your script would have to decide the conditions under which tail should be terminated and call kill to do so using the $pid returned by the open. (See the signal handler above.)

So then it falls to your script to decide when it should terminate. Whether because

If the latter, it will be necessary for you to detect the demise of the log producer in a timely manner, before re-entering the read state.

You appear to be under the impression that tail will be able to know when the program producing the logs isn't going to create another new one, and self-terminate, but that simply cannot be the case.

Perhaps that is the source of your problems with File::Tail and the POE solutions. Ie. Your expectations are wrong.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re^3: Tail'ing a log that frequently rolls over by BrowserUk
in thread Tail'ing a log that frequently rolls over by frd1963

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.