Computing.Net > Forums > Unix > Monitoring hanging/zombie processes

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Monitoring hanging/zombie processes

Reply to Message Icon

Name: axepert
Date: June 19, 2002 at 03:17:52 Pacific
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Frank
Date: June 19, 2002 at 08:35:35 Pacific
Reply:

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


0

Response Number 2
Name: axepert
Date: June 19, 2002 at 19:01:15 Pacific
Reply:

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 ?


0

Response Number 3
Name: frank
Date: June 20, 2002 at 02:26:42 Pacific
Reply:

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 CMDPID

for 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 THREAD

Below 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 Stopped

Additional for kernel threads:
O Nonexistent
R Running
S Sleeping

No RISK no fun

Frank


0

Response Number 4
Name: axepert
Date: June 21, 2002 at 00:32:22 Pacific
Reply:

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


0

Response Number 5
Name: Frank
Date: June 21, 2002 at 03:02:58 Pacific
Reply:

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 ksh

fg %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


0

Related Posts

See More



Response Number 6
Name: axepert
Date: June 23, 2002 at 20:32:09 Pacific
Reply:

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 :)


0

Response Number 7
Name: Kevan
Date: June 27, 2002 at 09:25:27 Pacific
Reply:

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 Stopped

Additional for kernel threads:
O Nonexistent
R Running
S Sleeping


0

Response Number 8
Name: frank
Date: July 4, 2002 at 05:34:43 Pacific
Reply:

kevan,

do you realy tryed this ?
On which OS does it works ?

No RISK no fun

Frank


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Monitoring hanging/zombie processes

Defunct and Zombie Process www.computing.net/answers/unix/defunct-and-zombie-process/2188.html

how to find the cause for zombie www.computing.net/answers/unix/how-to-find-the-cause-for-zombie/5372.html

unix process with recent cpu usage www.computing.net/answers/unix/unix-process-with-recent-cpu-usage/4892.html