Mailing me the Defunct/Zombie/Orphan

Hello I need a script which would mail me the list of processes which are zombie/defunct or orphan.

Please help me in this regard.

As a start you should do a ps, grep what you are looking for and pipe it into the mail command. Write it as a small script and let it be fired by cron to your needs.

how to figure out which processes are zombie/orphan/defunct out of a 'ps -ef' output

Thanks in advance!!

Something like this? (code is not tested)

count=`ps -ef |grep defunct |wc -l`
if [ $count > 10 ] ; then 
  echo " defunct process `ps -ef |grep defunct`" |mailx -s "defunct process" yourmailbox@abc.com
fi

thanks a lot .... how do i identify the zombie and orphan processes as well through a 'ps -ef' output.

thanks in advance!!

Check rdcwayx's code - he is grep'ing for "defunct" in the output of ps.

check for the status of 'Z' in ps output for zombie process

how does one identify the orphan processes in the typical output of a 'ps -ef' Are they the processes with PPID '0', since their parents are killed, the initi becomes their new parent.

and we exaactly to look for 'Z' in the ps-ef output for a zombie, I mean in the columns - PID, PPID, CMD, STIME, etc ?

thanks in advance!!