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;} }