Hi all,
i needed some mechanism to stop any process that takes
too long to complete. Basically I would see such a
"hung" process when issuing the ps -hx command. The
trouble with this command is that it truncates the
name of the application running associated with some
pid.
The idea was to run a perl program that would issue a
ps type command, then parse the output and kill only
some processes.

while(1){
@ps_line=`ps -eo pid,user,args,etime`;

for($i=0;$i<=$#ps_line;$i++){
chomp $ps_line[$i];
@one_line=split/\s+/,$ps_line[$i];
$pid=$one_line[0];
$user=$one_line[1];
$args=$one_line[2]."_".$one_line[3];
and so on...
}
there were some more ifs after that because I was
checking the elapsed time (etime) against some limits.
My problem is that first time I ran this perl program
everything worked fine... on subsequent times it
started to truncate the args so I can't get the full
name of the application for a given pid.
When I issue ps -eo pid,user,args,etime at the prompt
I can see the whole thing for args (something like
perl /home/oracle/dir1/sdir2/prg21.pl); when I run the
program and I print $args at standard output it gives
me the truncated thing.
ANybody any idea why?
Thanks,
Dan 


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/
_______________________________________________
Perl-Unix-Users mailing list. To unsubscribe go to 
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users

Reply via email to