Operating System - HP-UX
1831201 Members
2871 Online
110021 Solutions
New Discussion

Re: Killing Zombies through scripts

 
SOLVED
Go to solution
Doug_85
Regular Advisor

Killing Zombies through scripts

Running on HP-UX 11.0
L class server

Is there a way you can kill zombie processes without restarting the system? I was thinking about creating a shell script that finds the processes and kills them a couple times each day through the crontab. Any suggestions? Below is a partial script I thought I might use. I may try it with -11 or -14 instead of the -9 though.

ps -f |grep |kill -9

Any suggestions?

Thanks,
Doug
6 REPLIES 6
Mel Burslan
Honored Contributor

Re: Killing Zombies through scripts

Doug,

The term zombie process is derived affectionately based on the same concept of bodies which can not die. So, the short answer to your question is no. There is no way to kill a zombie process in short of a reboot.

Having said that, not all processes can be put into the zombie class. Some will disappear from the process listings after a while.

If you are having issues with too many zombie processes are hanging around, you may need to get to the bottom of the problem and talke to the developers of the software running on your system if it is internal or call the vendor and ask for their suggestion if this is a package purchased form them.

Sorry to be the bearer of the bad news.
________________________________
UNIX because I majored in cryptology...
Jeff Schussele
Honored Contributor

Re: Killing Zombies through scripts

Hi Doug,

As stated you *CAN'T* kill a zombie - BECAUSE THEY'RE ALREADY DEAD!!!!

That being said - IF they've been inherited - as a parent by init - PID #1 - then it has routines to reap it's children periodically.
IF they still have the org parent PID, then someone - in development - needs to go back to coding school. That's just lazy, lousy programming - period. In that case a stout hickory handle seems to work best for me.....

My 2 cents,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
PAVIC Thierry
Frequent Advisor
Solution

Re: Killing Zombies through scripts

Try this script, it will kill all defunct process if there is no dependent link with a father zombie




#!/bin/ksh
# --------------------------------------------------------------------------
# Fichier : Exp_KillPsDefunct.sh
# Action : Suppresion des process zombies
# Entree :
# Sortie :
# Usage :
# --------------------------------------------------------------------------
# Maintenance
# Date Auteur Action
# --------------------------------------------------------------------------
# 13/07/2004 TPA Creation
# --------------------------------------------------------------------------
#set -x
L_FicLst=/tmp/exploit/tmp/Exp_KillPsDefunct.txt
L_FicShell=/tmp/exploit/tmp/Exp_KillPsDefunct.sh
L_FicLog=/tmp/exploit/log/Exp_KillPsDefunct.log


# -- Raz
cat /dev/null > ${L_FicLst}
cat /dev/null > ${L_FicLog}

echo " -----------------------------------------------------------------" >> ${L_FicLog}
L_NbPs=`ps -ef |grep defunct|grep -v grep |wc -l`
echo "Nombre de process defunct : ${L_NbPs}">> ${L_FicLog}

echo " -----------------------------------------------------------------" >> ${L_FicLog}
echo "- Action : `date +%H:%M:%S` : Constitution de la liste des process" >> ${L_FicLog}
echo " -----------------------------------------------------------------" >> ${L_FicLog}
ps -ef |grep defunct|grep -v grep > ${L_FicLst}
cat ${L_FicLst} >> ${L_FicLog}

echo " -----------------------------------------------------------------" >> ${L_FicLog}
echo "- Action : `date +%H:%M:%S` : Constitution du shell" >> ${L_FicLog}
echo " -----------------------------------------------------------------" >> ${L_FicLog}
cat ${L_FicLst} |awk '{printf "kill -9 " $2 "\n"}' > ${L_FicShell}
cat ${L_FicShell} >> ${L_FicLog}

echo " -----------------------------------------------------------------" >> ${L_FicLog}
echo "- Action : `date +%H:%M:%S` : Constitution du shell" >> ${L_FicLog}
echo " -----------------------------------------------------------------" >> ${L_FicLog}
chmod 777 ${L_FicShell}

${L_FicShell} >> ${L_FicLog}

echo " -----------------------------------------------------------------" >> ${L_FicLog}
L_NbPs=`ps -ef |grep defunct|grep -v grep |wc -l`
echo "Nombre de process defunct : ${L_NbPs}">> ${L_FicLog}
YoungHwan, Ko
Valued Contributor

Re: Killing Zombies through scripts

Defunct and zomnbie processor is not running processor with resource.
If it is not removed until the system reboot. moreover it will have resource.
It have little effect using kill command.
This is normal state. When the processor halt, it will remain in defunct state. But it occupy little space than address territory.
If you sent signal to processor, which is already halt, you cannot have an influence on it. this proccessor will remove when the proccessor stop, and it will remain defunct processor until system reboot.
For more information refer to 'kill' and 'wait' man page.

And if you want to know system's cpu consumption use this command.
# UNIX95= ps -e -o "user,pcpu,args" | sort -rnk2 | more

Aagin And this problem may solve to upgrade support plus in lastest version.
download site is below.
http://www2.itrc.hp.com/service/patch/releaseIndexPage.do?BC=patch.breadcrumb.main


Geoff Wild
Honored Contributor

Re: Killing Zombies through scripts

Used to be able to kill most zombiew with:

logfile=/tmp/killzombies.log

for i in `ps -el|grep -v SZ|grep Z|awk '{print $5}'`
do
ps -ef|grep -v grep|grep ${i} >>$logfile 2>&1
kill -18 ${i}
done

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
twang
Honored Contributor

Re: Killing Zombies through scripts

In my past experience, zombie cannot be killed except reboot!