The job started at Fri Oct 11 07:01:10 BST 2013 log4j:WARN No appenders could be found for logger log4j:WARN Please initialize the log4j system properly. Error checking credentials The job completed at Fri Oct 11 08:01:10 BST 2013 #### use strict; use warnings; my $joblog = "/usr/logs/app.log"; my $M1 = "The job completed successfully"; my $M2 = "The job failed to start"; my $M3 = "The job failed to complete"; my $M4 = "The log does not exist"; my @tm = localtime; my ($started,$completed); chomp(my $jobdate=`date +"%a %b %d"`); my @output; if (($tm[2] == 9) && ($tm[1] == 00)) { if (-e $joblog) { local $/; open(my $fh, '<', $joblog); my @content = <$fh>; for(@content) { next unless (/^The job/); if (m/^The job started at $jobdate/){ $started = 1;} push (@output,"$M2") if ! $started; print @output and exit if ! $started; if (/^The job ended at $jobdate/){ $completed = 1; push (@output,"$M1"); print @output and exit if $started;} } @output="$M3" if ! $completed; print @output and exit if ! $completed; } else{print "$M4";} } else { print @output if defined;}