in reply to Tailing rolling logs

I believe you are reinventing File::Tail. If you'd rather get work done than resolving puzzles that have already been solved, use that module.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re: •Re: Tailing rolling logs
by RMGir (Prior) on Jan 30, 2004 at 13:17 UTC
Re: •Re: Tailing rolling logs
by Anonymous Monk on Jan 30, 2004 at 13:08 UTC
    Hi, yup, looked at File::Tail, didn't think it could work with rolling logs, unless I read the spec wrong. Anyway, no matter I think I found a way to check this using the inode of the file and the File::Stat module, added these lines to the main loop:
    if ( stat($file)->ino != $inode ) { # file has rolled if true close (FILE); open (FILE, "$file") or die "Cannot open file $file: $ +!\n"; $inode = stat(*FILE)->ino; }
    Obviously set $inode before entering the loop. Does seem to do the trick, but I need to do some more testing Thanks Jon
      Hi, yup, looked at File::Tail, didn't think it could work with rolling logs, unless I read the spec wrong.
      Did you miss this part?
      If the file does not get altered for a while, "File::Tail" gets suspicious and startschecking if the file was trun- cated, or moved and recreated. If anything like that had happened, "File::Tail" will quietly reopen the file, and continue reading. The only way to affect what happens on reopen is by setting the reset_tail parameter (see below). The effect of this is that the scripts need not be aware when the logfiles were rotated, they will just quietly work on.

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.

Re: •Re: Tailing rolling logs
by coec (Chaplain) on Jan 30, 2004 at 12:45 UTC
    Sweet module!
Re: •Re: Tailing rolling logs
by hmerrill (Friar) on Jan 30, 2004 at 12:59 UTC
    How do you know about all these "fairly obscure" modules? I've never seen File::Tail before - it's very nice!