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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|