tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Funk <>
Subject Re: Other question
Date Thu, 13 Jun 2002 15:07:03 GMT
For what its worth - I created (and use) a LifecycleListener that runs 
on startup which logs the process ID into a file called 
Which is created by a shell script called Below is all the 
code to get this to work. This code also assumes your current working 
directory is $CATALINA_HOME.

--Begin code
import org.apache.catalina.LifecycleEvent;

  * A helper for getting the PID of java so shutting down tomcat is MUCH
  * easier.
public class PidLifeCycle implements org.apache.catalina.LifecycleListener {
      public void lifecycleEvent(LifecycleEvent event)  {
         if ("start".equals(event.getType())) {
            try {
             Runtime.getRuntime().exec("/bin/sh bin/");
            } catch(Throwable e) {
--End Code

The code above will launch the following shell script. Should be in the 
bin/ directory of your tomcat installation.
--Begin Shell script
echo $PPID > logs/
--End Shell script

Then add the following into server.xml
--Begin server.xml snippet
<Listener className="PidLifeCycle" />
--End server.xml snippet


Rick Fincher wrote:
> Hi Laura,
> Tomcat actually does have a pid.  It is a java application.  Under Solaris
> if you do a ps -elf |grep nativ you will see a listing beginning with your
> JAVA_HOME and ending with ../bin/sparc/nativ_t.  That's the pid of the java
> virtual machine.  If you have multiple java apps running each will have a
> JVM so you may need to sort out which java pid is Tomcat.
> You can also use top after starting Tomcat.  You will see an entry for java
> in the table along with the pid and memory and cpu usage info.
> Rick

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message