in reply to Tail a rapidly changing 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.#!/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; }
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 | |
by BrowserUk (Patriarch) on Jan 16, 2010 at 15:28 UTC |