There is a nice lib for Perl for working with processes in Linux. And it could be used to get PIDs of processes that have been working more than some amount of time.
#!/usr/bin/perl -w use strict; use Proc::ProcessTable; my $period = time-(2*60*60); # in this case it's two hours my $t = new Proc::ProcessTable; foreach my $p ( @{$t->table} ) { if ( ($p->start() < $period) and ($p->cmndline() =~ /your_process_name/) ) { print $p->pid, "n"; } }
Now you can use simple wrapper to kill them gracefully.
Didn’t find the answer to your question? Ask it our administrators to reply we will publish on website.