Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically kill zombie processes mostly 'java" processes at tomcat

Status
Not open for further replies.

proggy

Programmer
Apr 21, 2002
46
US
please can anyone help me with ideas in killing these processes which doesn't die after i stop my tomcat..
 
Ok well this is one way to kill the tomcat processes, this is how I stop tomcat (yes, its dirty I know but it works 4 me).

First this is for a single tomcat server instance (worker):

#!/bin/bash
# Name: KT.sh
# Laurie Baker
# This kills off the Tomcat processes
# as tomcat objects to stopping when asked 'nice'
#
for PID in `ps -ef|grep tomcat| awk '{print $2}'`; do kill $PID ; done

# That feel-good factor..
ps -ef|grep tomcat|wc -l

Now if you have multipul workers, you need two of these KT1.sh & KT2.sh

#!/bin/bash
# Name: KT2.sh
# Laurie Baker
# This kills off the Tomcat 4-2 worker processes
#
for PID in `ps -ef tomcat4-2| awk '{print $2}'`; do kill $PID ; done

# That feel-good factor..
ps -ef tomcat4-2|wc -l

Ok the diference here is the use of ps -ef the a w[ide]w[ide]w[ide] output of the ps, this allows you (well grep!) to identify the path for tomcat4-1 or tomcat4-2 (worker), this may not make sence if you have never tried running two (or more) tomcat servers on the same Application server "you should try it" with the AJP conector in Apache it loadbalances a treat.
But thats for another day.

I hope this helps

Good luck
Laurie
 
Hi there, i appreciate ur answer, can you be more specific where should i use this script ?

Thanks,
 
Sorry I didn't make it clear b4, I (and I stress that this is my solution "and may not be the best") use this script to stop tomcat when I need to.

So where you would normaly use /usr/bin/tomcat4 start <cr> to start tomcat and /usr/bin/tomcat4 stop <cr> to stop tomcat, I continue to use the original /usr/bin/tomcat4 script to start it BUT I use /path/to/myscript/KT1 <cr> to stop tomcat &quot;Where <cr> is the Enter key or Carrage Return as it used to be called&quot;.

I have found that if someone has a http connection open then stopping tomcat with the /usr/bin/tomcat4 stop leaves processes behind (as in your situation) my way kills them dead.

I hope this helps to clarify?

Laurie.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top