in reply to Have script send email if it dies
More complex, yet also more robust (in my opinion) is to use Log::Log4perl along with Log::Dispatch::Email::MailSender, which does the trick well in my production code. Here's an example of how it captures the die for logging; you'd configure for emailing elsewhere, and the docs explain how:
$SIG{__DIE__} = sub { $Log::Log4perl::caller_depth++; my $logger = get_logger("YOUR_LOGGER_HERE"); $logger->fatal(@_); die @_; # Now terminate really };
This code is originally from the Log::Log4perl FAQ. The nice thing about using a logger, is that you can have it track "state"; sometimes simply having the dying error message isn't enough to track down an issue.
slight edit for clarification of email portion.----Asim, known to some as Woodrow.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Have script send email if it dies
by Anonymous Monk on Jul 21, 2006 at 15:34 UTC | |
by Asim (Hermit) on Jul 21, 2006 at 18:52 UTC |