For what its worth - I created (and use) a LifecycleListener that runs 
on startup which logs the process ID into a file called tomcat.pid. 
Which is created by a shell script called writepid.sh. 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/writepid.sh");
            } catch(Throwable e) {
               e.printStackTrace();
            }
         }
      }
}
--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/tomcat.pid
--End Shell script

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

-Tim

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:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to