1753753 Members
5538 Online
108799 Solutions
New Discussion

Perl Help

 
Pat Peter
Occasional Advisor

Perl Help

Hi,

I have a Perl script which executes hourly and generates some reports from the log files.

I send emails with the log data in case there are some errors in the logs.

Now the need is that I should not send the emails from 11PM till 6 AM in the morning since it is the maintenance window of some of our downstream systems.

The Perl script should get executed but the emails should not be send even if there are errors in the tiime between 11PM-6AM.

Can anyone please tell me how should I accomplish the task

Thanks,
Pat
1 REPLY 1
Muthukumar_5
Honored Contributor

Re: Perl Help

You can do this with localtime() to get the present time and check if it is 11PM to 6AM then, do not send mail.

Put check loop as,


my $hour=(localtime(time))[2];
if ( $hour => 23 || $hour <= 6 )
{
# Donot send mail
} else
{
# send mail
}

hth.
Easy to suggest when don't know about the problem!