in reply to tailing a file without printing its entire contents
If you place the seek, with to-end, above the while loop, it'll skip over the existing content the first time you read the file:
use strict; use warnings; my $logfile = "/var/log/httpd/agent1_access.log"; open(FH,'<',$logfile) || handle_error(); # typical open call for (;;) { seek FH, 0, 2; # this clears the eof flag on FH # eof reached on FH, but wait a second and maybe there will be mor +e output sleep 1; while (<FH>) { print "$_"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: tailing a file without printing its entire contents
by Anonymous Monk on Aug 07, 2014 at 12:17 UTC |