in reply to Re^2: Watch log for string (tail -f)
in thread Watch log for string (tail -f)
tail -f doesn't end until you interrupt it. Try something like this:
#! perl -slw use strict; my $pid = open TAIL, '-|', 'tail -f theLog' or die $!; my @matches; while( @matched <3 and defined( $_ = <TAIL> ) ) { push @matches, $_ if /the search term/; } kill 2, $pid; ## do something with the 3 lines in @matches.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Watch log for string (tail -f)
by bimleshsharma (Beadle) on Oct 12, 2012 at 07:39 UTC | |
|
Re^4: Watch log for string (tail -f)
by Skootaman (Novice) on Sep 30, 2013 at 11:44 UTC |