Hello Monks,
I'm trying to search logs every 2 hours for string, and if found then sendmail should kick in. I'm trying to find the best way to run my cron jobs every 2 hours without getting repetitive emails.
I decided just to search for the string, push it into my array, then change it's format so the next run for my script it doesn't catch it.
open SwitchLogs, $logFile or die "Could not open $logFile: $!"; while (<SwitchLogs>) { chomp; my $line = $_; if($line =~ m/PHY-4-EXCESSIVE_ERRORS/){ push(@err, "$line\n"); s/PHY-4-EXCESSIVE_ERRORS/PHY_4_EXCESSIVE-ERRORS/g; $sendemail = 1; } } close SwitchLogs;
I need help with the replace, how do I make it do the replace? Currently the script runs but still every 2 hours I keep getting the same email because the replace doesn't work. I know I'm missing something very basic.
In reply to Search logs with crontab by hmb104
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |