in reply to extract last 1 min log and find a string
use File::stat; use Time::localtime; my $fh = "/daily20170718120401.log"; my $target = "48 processes started"; my $count == 0; while ( $count< 4){ my $timestamp = ctime(stat($fh)->mtime); print "$timestamp\n"; sleep(30); my $timestamp2 = ctime(stat($fh)->mtime); print "$timestamp2\n"; if ($timestamp eq $timestamp2) { my $bw = File::ReadBackwards->new("backwards.txt") or die $!; my $line; while (defined($line = $bw->readline)) { chomp $line; if ($line =~ /target/) { print "found\n"; $count = 4; } } $bw->close(); } } else{print "changed\n"; $count += 1;} }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: extract last 1 min log and find a string
by poj (Abbot) on Jul 24, 2017 at 19:38 UTC | |
by ytjPerl (Scribe) on Jul 24, 2017 at 19:55 UTC | |
by poj (Abbot) on Jul 24, 2017 at 20:19 UTC | |
by marto (Cardinal) on Jul 25, 2017 at 09:26 UTC |