cron - Perl alarm() or Time::Out Without Kernel SIG -
i have script misbehaves while communicating web server. server hangs or slow respond data.
i using alarm()
hack script terminate—so not flood system threads—but causes cron error, alerts sysadmin, doesn't want 200 emails produces when system has fallen over.
is there alternative method of terminating script (or apiquery, if need be) won't cause non-ok exit , corresponding email?
you can throw exception in signal handler, , catch elsewhere.
my $success = eval { local $sig{alrm} = sub { die "failure" }; alarm 10; do_something_long(); alarm 0; 1; }; if (!$success) { warn "timeout!\n" if $verbose; exit 0; }
Comments
Post a Comment