in reply to Tail a rapidly changing file

I would just write my own code, it's pretty easy:

#!/usr/bin/perl use strict; use warnings; use Fcntl qw/:seek/; my $file='my.log'; # position to end open(FILE,$file) || die "$file: $!"; seek(FILE,0,SEEK_END) || die "Seek: $!"; my $pos=tell(FILE); close FILE; while(1) { sleep(5*60); # every 5 minutes open(FILE,$file) || die "$file: $!"; seek(FILE,$pos,SEEK_SET) || die "Seek: $!"; while (<FILE>) { # do something with $_ lines } $pos=tell(FILE); # update close FILE; }
Send it the kill signal when you're done with it, or you could get fancy by adding code to abort when it sees something or other.

HTH,
SSF

Replies are listed 'Best First'.
Re^2: Tail a rapidly changing file
by matze77 (Friar) on Jan 16, 2010 at 15:09 UTC

    Hello!
    I dont know what use Fcntl qw/:seek/; accomplishes if someone got the time maybe he/she could explain?
    Thanks
    MH

      I dont know what use Fcntl qw/:seek/; accomplishes ...

      It imports the constants SEEK_SET SEEK_CUR SEEK_END.


      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.