Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Does anyone have any handy tips on how to monitor hanging/zombie processes ?
I thought about combining the "ps" command with awk, but it's not really very helpful :
ps -ef |awk '{if ( $3= 1) print $1," "$2," " $3," "$5, " "$8 }' .. etc
Does anyone have any better ideas ? Thanks :)
Cheers,
axepert

Hi axepert,
seems so that there are some mistakes in your script:
1) $3 displayes the PPID and not the status of the process.
2) there is no need to use the , and " " in combination, you can use only one of them.What do you would like to see hanging (blocking) or defunct (Zombie)process
When you say monitoring you mean monitoring or only viewing / checking ?
No RISK no fun,
Frank

Hi Frank,
Thanks for replying.
Using $3, I can view processes that does not have a PPID, in this case I assume that it is 1.
Basically, I would like to know which commands to use to get a list of hanging/zombie processes that are currently running. Any ideas ?

Hi axepert,
only to make sure that we understood the same by hanging and defunct process a short definition below:
Zombie:
Is a process that has exited and has a parent that has not yet waited for the
process is marked .Haning:
A process that is blocked trying to exit is marked .for X/Open Standards you can use:
ps -el | awk ' $2!="A" {print $2,$14 "PID =",$4}' |grep -v CMDPIDfor Berkley Standards you can use:
ps ax |awk ' $3!="A" {print $3,$5" PID=",$1} |grep -v STAT
In combination of thread and proces use:
ps -emo THREADBelow find a list about the meaning of the status flag:
For processes:
O Nonexistent
A Active
W Swapped
I Idle (waiting for startup)
Z Canceled
T StoppedAdditional for kernel threads:
O Nonexistent
R Running
S SleepingNo RISK no fun
Frank

Thanks for that Frank, really appreciate it.
The commands that you provided would list the status process of all non-active processes. However, how can I use this list to pin point the processes that are hanging ?
Basically, I need to know which process have stopped running so that I can then restart it if required.
Thanks,
axepert

axepert,
I am confused.
haning and stopping is different.e.g.
$ ps -l
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
200001 A 61334 39248 40970 3 69 24 3475a 440 pts/2 0:00 ps
240001 A 61334 40970 38908 0 42 24 226b1 572 pts/2 0:00 ksh
$ ping -c 10 1.1.1.1
PING 1.1.1.1: (1.1.1.1): 56 data bytes
[1] + Stopped (SIGTSTP) ping -c 10 1.1.1.1
$ jobs
[1] + Stopped (SIGTSTP) ping -c 10 1.1.1.1
$ ps -l
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
200001 A 61334 29732 40970 2 69 24 2723b 412 pts/2 0:00 ps
20200011 T 61334 39250 40970 0 68 24 151e2 332 70742e6c pts/2 0:00 ping
240001 A 61334 40970 38908 1 68 24 226b1 572 pts/2 0:00 kshfg %1
Is it this what you was looking for ?
If not describe what you want to see without using different words with different meanings also would be easier for me if you can tell me on which kind of UNIX you are using.A stopped process recives the SIGTSTP signal which is ok for some programes.
A haning process can be is a process which runs in e.g. endless loop
A defunct process is a process which will end but cannot end (lost parent)
The meaning of the status flag is described in a previous mail.
Regards Frank

Hi Frank,
Thanks again for your reply. I managed to find some information on what I'm looking for.
Basically, I want to find out about hanging/runaway processes. I found that this cannot be easily determined, and I will have to look at the STIME column to see how when the process has been running and then only decide if it should be terminated.
Thanks again for your help :)

I wrote a script that kills zombie processes.
ps -el | awk '{print $2, $4, $5}' | awk '$1=="Z" {print $1, $2, $3}' \
{while read zomb zpid zpid2
do
printf "Process id $zpid and $zpid2 is a $zomb zombie \n"
kill -9 $zpid $zpid2
done
}
For processes:
O Nonexistent
A Active
W Swapped
I Idle (waiting for startup)
Z Canceled
T StoppedAdditional for kernel threads:
O Nonexistent
R Running
S Sleeping

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |