#!/usr/bin/perl use Sys::Syslog qw( :DEFAULT setlogsock); use Proc::ProcessTable; use Proc::ProcessTable::Process; setlogsock('unix'); openlog($0,'','user'); $t = new Proc::ProcessTable; foreach $p ( @{$t->table} ){ next unless $p->cmndline =~ m#^/usr/bin/qpsmtpd-forkserver#; my $diff = time - $p->start; # Process is more than 30 minutes old ? if ($diff > 1800){ syslog('info', "Killing PID " . $p->pid . "(" . $p->cmndline . ") because it looks like a stalled qpsmtpd process"); $p->kill(9); } } closelog;