in reply to Re: Tail'ing a log that frequently rolls over
in thread Tail'ing a log that frequently rolls over
You could try this:
use strict; use warnings; use POSIX; use Perl::Unsafe::Signals; my $appLog = '/tmp/t.txt'; my $error = 'Fatal Error'; exit if (my $pid = fork); defined($pid) or die "Can't fork: $!"; POSIX:setsid() or die "Can't setsid: $!"; my $tail = open(LOG,"/usr/local/bin/tail -F $appLog|") or die "Can't tail: $!"; $SIG{INT} = sub { close LOG; kill 3, $tail; exit; }; $SIG{TERM} = $SIG{INT}; $SIG{PIPE} = 'IGNORE'; $SIG{HUP} = 'IGNORE'; UNSAFE_SIGNALS { while (<LOG>) { #&pageMe if /$error/; print; } };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Tail'ing a log that frequently rolls over
by hbm (Hermit) on Jan 15, 2009 at 18:43 UTC |