1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| sub ps{
my ($pidfile)=@_;
my $exec_time = 0;
my $exec_script = '';
my $exec_pid = 0;
uptime($pidfile, \$exec_script, \$exec_pid, \$exec_time);
printf ("\n[$exec_script] already running with pid [$exec_pid] since [$exec_time]\n");
}
sub uptime{
my ($pidfile, $exec_script, $exec_pid, $exec_time) = @_;
my $my_ps = new Proc::ProcessTable;
foreach my $my_proc ( @{$my_ps->table} ){
if($pidfile->pid eq $my_proc->pid){
${$exec_time} = sec2time(time - $my_proc->start);
${$exec_script} = $my_proc->cmndline;
${$exec_pid} = $my_proc->pid;
}
}
} |
Partager