On Thu, May 24, 2001 at 02:37:18PM -0400, Craig Moynes/Markham/IBM wrote:
>
> This is a problem with tail that I have run into as well.
>
> If the file size gets reset the stored location of EOF remains the same
> which is a problem. As the file is written too the size is still below that
> of what tail is looking at. You can add a stat check to watch filesize and
> reset the counter when the size is smaller than the previous one.
>
> I think there was another issue with using tail, hmmmmm.
>
> You can test it out on the command line though to ensure I have my brain in
> alignment.
>
> Ohh the other problem ...
>
> Your script will wait for more data from tail, and if the file size is
> reset it just sits there. To solve this I created a controller process
> that spawns off the log reader and then the controller monitors the logfile
> size, if it drops below the last size it kills off the log reader process
> and respawns it.
>
>
> Any other solutions perl gods ?
There are several alternatives offered in perlfaq5 (search for 'How do
I do a "tail -f" in perl?'[1]). Since the solutions there are variations
on
loop forever
reposition
read to eof
sleep a bit
end loop
they may (although I haven't tested it) get around the problems you
describe.
Walt
1. Or, alternatively, "perldoc -q tail".
--
Walter C. Mankowski
Senior Software Engineer Myxa Corporation
phone: (610) 234-2626 fax: (610) 234-2640
email: [EMAIL PROTECTED] http://www.myxa.com