I have a simple little perl program that monitors the email log file for
rejected messages (see below). I start the program using "nohup script.pl &"
and it works fine, sending me an email with info about each rejected
message. However, it just dies out randomly after a day or so for no reason
that I can figure. The script is still there as a process, but it doesn't
perform.
Is there another way I should be approaching this task?
#!/usr/bin/perl
$maillog = "/var/log/maillog";
$TAIL = "/usr/bin/tail";
open(MAILLOG,"$TAIL -f $maillog |") || die("Can't $TAIL -f $maillog");
while($line = <MAILLOG>) {
if ($line =~ /blocked/) {
system("echo '$line' | mail -s 'RBL rejection' foo\@bar.com");
}
}
close(MAILLOG);
exit(1);