You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by raj kumar <bp...@gmail.com> on 2009/12/02 07:30:06 UTC

How to get java process id of a user running tomcat

Hi friends,

When i ran tomcat and shut it down my java process is not closing along with
shutdown.i need to kill it explicitly. So  I would like to know how to
identify the java process of the logged in user who started the server. so
that i can kill the process id from the shutdown.sh script itself. Please
help me.

Tomcat: jakarta-tomcat-5.0.28
Java : j2sdk1.4.2
OS: SunOS

Thanks,
Phani.

Re: How to get java process id of a user running tomcat

Posted by André Warnier <aw...@ice-sa.com>.
Caldarale, Charles R wrote:
>> From: Pierre Goupil [mailto:goupilpierre@gmail.com]
>> Subject: Re: How to get java process id of a user running tomcat
>>
>> " jps -mlv " will give you the PIDs of all running Java processes. Plus
>> it's a part of the standard SUN JVM.
> 
> But not for the OP, who is running an unsupported version of Tomcat on an unsupported JVM that predates the jps tool.  As Pid suggested, the correct thing to do is to fix the webapp so it properly manages the threads it has started.  Attack the problem, not the symptom.
> 
For a long while on this thread, I had been waiting for someone to say that.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to get java process id of a user running tomcat

Posted by Michael Dockery <do...@yahoo.com>.
i agree with Chuck
 and would add these commands for consideration on a windows box

netstat -ano will show the pid of any java job which is tied to a tcp port

likewise (on windows only):

 wmic process get /all /value

   is another win vista/win7/xp pro+ command
     which will show all the output from all pid's
       including the command line options

or more specifically something like this:

 wmic process where "commandline like '%java%'" get commandline, processid

hope this helps someone out there



________________________________
From: "Caldarale, Charles R" <Ch...@unisys.com>
To: Tomcat Users List <us...@tomcat.apache.org>
Sent: Wed, December 2, 2009 9:32:18 AM
Subject: RE: How to get java process id of a user running tomcat

> From: Pierre Goupil [mailto:goupilpierre@gmail.com]
> Subject: Re: How to get java process id of a user running tomcat
> 
> " jps -mlv " will give you the PIDs of all running Java processes. Plus
> it's a part of the standard SUN JVM.

But not for the OP, who is running an unsupported version of Tomcat on an unsupported JVM that predates the jps tool.  As Pid suggested, the correct thing to do is to fix the webapp so it properly manages the threads it has started.  Attack the problem, not the symptom.

- Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


      

RE: How to get java process id of a user running tomcat

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Pierre Goupil [mailto:goupilpierre@gmail.com]
> Subject: Re: How to get java process id of a user running tomcat
> 
> " jps -mlv " will give you the PIDs of all running Java processes. Plus
> it's a part of the standard SUN JVM.

But not for the OP, who is running an unsupported version of Tomcat on an unsupported JVM that predates the jps tool.  As Pid suggested, the correct thing to do is to fix the webapp so it properly manages the threads it has started.  Attack the problem, not the symptom.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


Re: How to get java process id of a user running tomcat

Posted by Pierre Goupil <go...@gmail.com>.
>>> So  I would like to know how to identify the java process of the logged
in user who started the server

" jps -mlv " will give you the PIDs of all running Java processes. Plus it's
a part of the standard SUN JVM.

Regards

Pierre



On Wed, Dec 2, 2009 at 7:30 AM, raj kumar <bp...@gmail.com> wrote:

> Hi friends,
>
> When i ran tomcat and shut it down my java process is not closing along
> with
> shutdown.i need to kill it explicitly. So  I would like to know how to
> identify the java process of the logged in user who started the server. so
> that i can kill the process id from the shutdown.sh script itself. Please
> help me.
>
> Tomcat: jakarta-tomcat-5.0.28
> Java : j2sdk1.4.2
> OS: SunOS
>
> Thanks,
> Phani.
>



-- 
Rien de grand ne s'est accompli dans le monde sans passion.

(G.W.F. Hegel, philosophe allemand)

Re: How to get java process id of a user running tomcat

Posted by Tobias Crefeld <tc...@cataneo.eu>.
Am Wed, 2 Dec 2009 12:00:06 +0530
schrieb raj kumar <bp...@gmail.com>:

> Tomcat: jakarta-tomcat-5.0.28
> Java : j2sdk1.4.2
> OS: SunOS

ps -fu TomcatsUsername |grep java |grep -v grep |cut -f2 -d" "

If the release of your SunOS is as antique as the rest of your software
it's possible that one of these commands doesn't work.


Regards,
 Tobias.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to get java process id of a user running tomcat

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Felix,

On 12/2/2009 3:54 PM, Felix Schumacher wrote:
> I really waited for André to rant about the perl
> parts...especially using tons of grep before an awk in a system call
> from perl. Cool :)

Wesley's script was as elegant as it was necessary. I didn't catch the
humorous use of awk /after/ grep which is pretty funny... especially
when Perl is already there to do your searching for you.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksW2m4ACgkQ9CaO5/Lv0PB6PQCgl8xQLiSPAP12zOySIL9QrQNI
OzcAn1305ibLrKOUYDuCo23VBoUz126J
=GFQt
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: How to get java process id of a user running tomcat

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: André Warnier [mailto:aw@ice-sa.com]
> Subject: Re: How to get java process id of a user running tomcat
> 
> But Chuck apparently got tired of simmering in the background, and
> could stop himself no longer..

You confuse "tired of simmering" with "waking up"... (GMT-6 :-)

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to get java process id of a user running tomcat

Posted by André Warnier <aw...@ice-sa.com>.
Felix Schumacher wrote:
> Well, Chuck said the most important bit about finding the root of the
> problem. I really waited for André to rant about the perl
> parts...especially using tons of grep before an awk in a system call
> from perl. Cool :)
> 
Well, in my defense, I just turned off mentally about that thread after 
the first couple of phrases of the original OP post, thinking "why does 
he not fix his application to not do that ?", so I missed the perl + 
system calls part.
As the responses were accumulating, I was wondering how long it would 
take one of the gurus here to point this out.
But Chuck apparently got tired of simmering in the background, and could 
stop himself no longer..
;-)

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to get java process id of a user running tomcat

Posted by Felix Schumacher <fe...@internetallee.de>.
Am Mittwoch, den 02.12.2009, 15:42 -0500 schrieb Christopher Schultz:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Felix,
> 
> On 12/2/2009 5:48 AM, Felix Schumacher wrote:
> > Have you tried to use the evironment variable CATALINA_PID?
> > That variable should be set to a file(name) in which the pid of tomcat
> > will be stored. You can take a look at bin/catalina.sh for more
> > information.
> 
> Aw! I failed to read your response before posting: I said the same thing.
> 
> As creative as some of these answers are, they are almost all foolish
> when a clear alternative is present. Of course, if the OP isn't using
> catalina.sh to start Tomcat... :(
Well, Chuck said the most important bit about finding the root of the
problem. I really waited for André to rant about the perl
parts...especially using tons of grep before an awk in a system call
from perl. Cool :)

Felix
> 
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAksW0ScACgkQ9CaO5/Lv0PCeqACgsEBwQD/lX48Qh1h7qvG5h5h1
> T6oAoMLLMy9/4HeP2d5osydF/9lPRYB6
> =Dugv
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to get java process id of a user running tomcat

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Felix,

On 12/2/2009 5:48 AM, Felix Schumacher wrote:
> Have you tried to use the evironment variable CATALINA_PID?
> That variable should be set to a file(name) in which the pid of tomcat
> will be stored. You can take a look at bin/catalina.sh for more
> information.

Aw! I failed to read your response before posting: I said the same thing.

As creative as some of these answers are, they are almost all foolish
when a clear alternative is present. Of course, if the OP isn't using
catalina.sh to start Tomcat... :(

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksW0ScACgkQ9CaO5/Lv0PCeqACgsEBwQD/lX48Qh1h7qvG5h5h1
T6oAoMLLMy9/4HeP2d5osydF/9lPRYB6
=Dugv
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: How to get java process id of a user running tomcat

Posted by Felix Schumacher <fe...@internetallee.de>.
Have you tried to use the evironment variable CATALINA_PID?
That variable should be set to a file(name) in which the pid of tomcat
will be stored. You can take a look at bin/catalina.sh for more
information.

Bye
 Felix
On Wed, 2 Dec 2009 08:57:45 -0000, <Ge...@gta-travel.com>
wrote:
> Hi
> Have a look at the Redhat/Centos startup scripts to see how they do
> that.
> 
> If you are running a other linux os then use ps and look for java
> processes. Normally the java process will have a catalina param
> somewhere so that is usefull to grep for. 
> 
> Regards
> 
> -----Original Message-----
> From: raj kumar [mailto:bprajkumar121@gmail.com] 
> Sent: 02 December 2009 06:30
> To: users@tomcat.apache.org
> Subject: How to get java process id of a user running tomcat
> 
> Hi friends,
> 
> When i ran tomcat and shut it down my java process is not closing along
> with
> shutdown.i need to kill it explicitly. So  I would like to know how to
> identify the java process of the logged in user who started the server.
> so
> that i can kill the process id from the shutdown.sh script itself.
> Please
> help me.
> 
> Tomcat: jakarta-tomcat-5.0.28
> Java : j2sdk1.4.2
> OS: SunOS
> 
> Thanks,
> Phani.
> 
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email 
> ______________________________________________________________________
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: How to get java process id of a user running tomcat

Posted by Ge...@gta-travel.com.
Hi
Have a look at the Redhat/Centos startup scripts to see how they do
that.

If you are running a other linux os then use ps and look for java
processes. Normally the java process will have a catalina param
somewhere so that is usefull to grep for. 

Regards

-----Original Message-----
From: raj kumar [mailto:bprajkumar121@gmail.com] 
Sent: 02 December 2009 06:30
To: users@tomcat.apache.org
Subject: How to get java process id of a user running tomcat

Hi friends,

When i ran tomcat and shut it down my java process is not closing along
with
shutdown.i need to kill it explicitly. So  I would like to know how to
identify the java process of the logged in user who started the server.
so
that i can kill the process id from the shutdown.sh script itself.
Please
help me.

Tomcat: jakarta-tomcat-5.0.28
Java : j2sdk1.4.2
OS: SunOS

Thanks,
Phani.

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to get java process id of a user running tomcat

Posted by Pid <pi...@pidster.com>.
On 02/12/2009 06:30, raj kumar wrote:
> Hi friends,
>
> When i ran tomcat and shut it down my java process is not closing along with
> shutdown.i need to kill it explicitly. So  I would like to know how to
> identify the java process of the logged in user who started the server. so
> that i can kill the process id from the shutdown.sh script itself. Please
> help me.

The jsvc binary supplied with Tomcat starts the server, records the 
process id and uses it to stop the server.  In my experience it's never 
failed to stop the server, so you may find that using it is an effective 
solution.

However, in aggressively shutting down Tomcat, you may be hiding an 
issue that is contained in the application.  I would recommend that you 
investigate why Tomcat is not shutting down and see if you can address 
the problem before taking more drastic action.

Try taking a thread dump after shutdown, to see which threads are still 
active.


p




> Tomcat: jakarta-tomcat-5.0.28
> Java : j2sdk1.4.2
> OS: SunOS
>
> Thanks,
> Phani.
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: How to get java process id of a user running tomcat

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Gerhardus.Geldenhuis@gta-travel.com
> [mailto:Gerhardus.Geldenhuis@gta-travel.com]
> Subject: RE: How to get java process id of a user running tomcat
> 
> Out of interest the man page for jps states:
> NOTE:  This  utility  is unsupported and may not be available in future
> versions of the JDK.

That disclaimer is present on pretty much every JDK tool that Sun provides, other than those absolutely required for development, such as javac.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


Re: How to get java process id of a user running tomcat

Posted by David kerber <dc...@verizon.net>.
Gerhardus.Geldenhuis@gta-travel.com wrote:
> Thanks for the reply,
> 
> Out of interest the man page for jps states:
> NOTE:  This  utility  is unsupported and may not be available in future versions of the JDK. It is not 
> currently available on Windows 98 and Windows ME platforms.
> 
> This might just be a entry that has not been removed... and the utility is supported... and available in future versions.

Note the key word "may", instead of "will".  They're just saying they 
aren't promising to give it to you in the future; they aren't saying 
they won't.

D


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: How to get java process id of a user running tomcat

Posted by Ge...@gta-travel.com.
Thanks for the reply,

Out of interest the man page for jps states:
NOTE:  This  utility  is unsupported and may not be available in future versions of the JDK. It is not 
currently available on Windows 98 and Windows ME platforms.

This might just be a entry that has not been removed... and the utility is supported... and available in future versions.


-----Original Message-----
From: Pid [mailto:pid@pidster.com] 
Sent: 03 December 2009 17:37
To: users@tomcat.apache.org
Subject: Re: How to get java process id of a user running tomcat

On 03/12/2009 17:09, Gerhardus.Geldenhuis@gta-travel.com wrote:
> Hi
> Me being the one who made the ridiculous suggestion of using ps, am now enlightened and will be using jps -mlv and spreading the word...
>
> That being said is there any opinions about the soundness of using the Redhat/Centos startup/shutdown script for Tomcat?

No idea how it works, but presumably it was written to shutdown the 
server, ergo it should be reasonable to use it as intended.

If Tomcat doesn't stop, find out why.


p


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

Re: How to get java process id of a user running tomcat

Posted by Pid <pi...@pidster.com>.
On 03/12/2009 17:09, Gerhardus.Geldenhuis@gta-travel.com wrote:
> Hi
> Me being the one who made the ridiculous suggestion of using ps, am now enlightened and will be using jps -mlv and spreading the word...
>
> That being said is there any opinions about the soundness of using the Redhat/Centos startup/shutdown script for Tomcat?

No idea how it works, but presumably it was written to shutdown the 
server, ergo it should be reasonable to use it as intended.

If Tomcat doesn't stop, find out why.


p


> Regards
>
>
> -----Original Message-----
> From: Christopher Schultz [mailto:chris@christopherschultz.net]
> Sent: 02 December 2009 20:40
> To: Tomcat Users List
> Subject: Re: How to get java process id of a user running tomcat
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Phani,
>
> On 12/2/2009 1:30 AM, raj kumar wrote:
>> When i ran tomcat and shut it down my java process is not closing along with
>> shutdown.
>
> See others' responses for why you should have to do this. Otherwise...
>
>> i need to kill it explicitly. So  I would like to know how to
>> identify the java process of the logged in user who started the server. so
>> that i can kill the process id from the shutdown.sh script itself.
>
> You won't be using the shutdown.sh script to kill Tomcat unless you hack
> it up to do that. I'd recommend against that.
>
> What I would recommend is using the CATALINA_PID environment variable
> helpfully documented in bin/catalina.sh:
>
> # Environment Variable Prequisites
> [...]
> #   CATALINA_PID    (Optional) Path of the file which should contains
> #                   the pid of catalina startup java process, when
> #                   start (fork) is used
>
> Try setting this environment variable to something like
> "/var/run/tomcat.pid" and you should get a file in that location
> containing the pid of the Java process started by Tomcat.
>
> Then, you can do something like:
>
> $ kill -9 `cat /var/run/tomcat.pid`
>
> Forget all these ridiculous suggestions of running 'ps' and grepping the
> output for all kinds of crazy strings. That may or may not work at all.
> The above strategy was intended by the Tomcat developers to be used to
> capture the PID of the Java process, so go ahead and use that.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAksW0KwACgkQ9CaO5/Lv0PA7uQCgxBiy3snTbF49e8FXPp/+qARn
> qncAoI4/CLEItiHOiZxCioRfpHcCiGZ5
> =AP2a
> -----END PGP SIGNATURE-----
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to get java process id of a user running tomcat

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Gerhardus,

On 12/3/2009 12:09 PM, Gerhardus.Geldenhuis@gta-travel.com wrote:
> Me being the one who made the ridiculous suggestion of using ps,
> am now enlightened and will be using jps -mlv and spreading the
> word...

I would still use CATALINA_PID and not use any kind of process listing
along with pattern matching. You're bound to miss cases and kill the
wrong process(es).

> That being said is there any opinions about the soundness of using
> the Redhat/Centos startup/shutdown script for Tomcat?

If you are using a package-managed version of Tomcat, using their
scripts would seem to be essential. Hopefully, those package-managed
scripts ultimately call Tomcat's built-in scripts to be as compatible as
possible.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksYGf8ACgkQ9CaO5/Lv0PBmgACgwwi78qECCPUUH8eSzwzvkb7V
Gw0Ani1Yc8pO60wb4l4OydFje67EF0Lh
=XuDH
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: How to get java process id of a user running tomcat

Posted by Ge...@gta-travel.com.
Hi
Me being the one who made the ridiculous suggestion of using ps, am now enlightened and will be using jps -mlv and spreading the word...

That being said is there any opinions about the soundness of using the Redhat/Centos startup/shutdown script for Tomcat?

Regards


-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net] 
Sent: 02 December 2009 20:40
To: Tomcat Users List
Subject: Re: How to get java process id of a user running tomcat

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Phani,

On 12/2/2009 1:30 AM, raj kumar wrote:
> When i ran tomcat and shut it down my java process is not closing along with
> shutdown.

See others' responses for why you should have to do this. Otherwise...

> i need to kill it explicitly. So  I would like to know how to
> identify the java process of the logged in user who started the server. so
> that i can kill the process id from the shutdown.sh script itself.

You won't be using the shutdown.sh script to kill Tomcat unless you hack
it up to do that. I'd recommend against that.

What I would recommend is using the CATALINA_PID environment variable
helpfully documented in bin/catalina.sh:

# Environment Variable Prequisites
[...]
#   CATALINA_PID    (Optional) Path of the file which should contains
#                   the pid of catalina startup java process, when
#                   start (fork) is used

Try setting this environment variable to something like
"/var/run/tomcat.pid" and you should get a file in that location
containing the pid of the Java process started by Tomcat.

Then, you can do something like:

$ kill -9 `cat /var/run/tomcat.pid`

Forget all these ridiculous suggestions of running 'ps' and grepping the
output for all kinds of crazy strings. That may or may not work at all.
The above strategy was intended by the Tomcat developers to be used to
capture the PID of the Java process, so go ahead and use that.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksW0KwACgkQ9CaO5/Lv0PA7uQCgxBiy3snTbF49e8FXPp/+qARn
qncAoI4/CLEItiHOiZxCioRfpHcCiGZ5
=AP2a
-----END PGP SIGNATURE-----

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

Re: How to get java process id of a user running tomcat

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Phani,

On 12/2/2009 1:30 AM, raj kumar wrote:
> When i ran tomcat and shut it down my java process is not closing along with
> shutdown.

See others' responses for why you should have to do this. Otherwise...

> i need to kill it explicitly. So  I would like to know how to
> identify the java process of the logged in user who started the server. so
> that i can kill the process id from the shutdown.sh script itself.

You won't be using the shutdown.sh script to kill Tomcat unless you hack
it up to do that. I'd recommend against that.

What I would recommend is using the CATALINA_PID environment variable
helpfully documented in bin/catalina.sh:

# Environment Variable Prequisites
[...]
#   CATALINA_PID    (Optional) Path of the file which should contains
#                   the pid of catalina startup java process, when
#                   start (fork) is used

Try setting this environment variable to something like
"/var/run/tomcat.pid" and you should get a file in that location
containing the pid of the Java process started by Tomcat.

Then, you can do something like:

$ kill -9 `cat /var/run/tomcat.pid`

Forget all these ridiculous suggestions of running 'ps' and grepping the
output for all kinds of crazy strings. That may or may not work at all.
The above strategy was intended by the Tomcat developers to be used to
capture the PID of the Java process, so go ahead and use that.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksW0KwACgkQ9CaO5/Lv0PA7uQCgxBiy3snTbF49e8FXPp/+qARn
qncAoI4/CLEItiHOiZxCioRfpHcCiGZ5
=AP2a
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to get java process id of a user running tomcat

Posted by Tobias Crefeld <tc...@cataneo.eu>.
Am Wed, 2 Dec 2009 12:00:06 +0530
schrieb raj kumar <bp...@gmail.com>:

> When i ran tomcat and shut it down my java process is not closing
> along with shutdown.i need to kill it explicitly. So  I would like to

BTW: How much memory is reserved for your Tomcat-JVM ($JAVA_OPTS) and
how much memory has your server available?


Regards,
 Tobias.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to get java process id of a user running tomcat

Posted by Wesley Schwengle <we...@is.online.nl>.
On 02.12.09 07:30 raj kumar wrote:

> When i ran tomcat and shut it down my java process is not closing along with
> shutdown.i need to kill it explicitly. So  I would like to know how to
> identify the java process of the logged in user who started the server. so
> that i can kill the process id from the shutdown.sh script itself. Please

Hi, this is how I do it (extracted from a perl script):

     if ($uname eq "Linux") {
         $cmd = "pgrep -lf -u $user java | grep -v grep | grep '$name'| awk '{print \$1}'";
     } elsif ($uname eq "Solaris") {
         $cmd = "/usr/ucb/ps auxww | grep '^$user' | grep java | grep -v grep | grep -w '$name' | awk '{print \$2}'";
     }

     open(PIDS, "$cmd|");
     my @pids = <PIDS>;
     close(PIDS);

     foreach (@pids) {
         if (/^(\d+)/) {
             my $pid = $1;
             if (`ps -o fname -p $pid` =~ /java/) {
                 printf STDERR "Killing process %d ..\n", $pid;
                 kill(15, $pid);
                 sleep(5);
                 kill(9, $pid);
             }
         }
     }


Cheers,
Wesley

-- 
Online Broadband BV, http://www.online.nl, http://www.euronet.nl
Wesley Schwengle, System Administrator, IT Operations (Database/Application Management)
Muiderstraat 1, PO BOX 10241, 1001 EE Amsterdam, T: +31 20 5355555, F: +31 20 5355749

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to get java process id of a user running tomcat

Posted by Anirban Talukdar <ta...@gmail.com>.
Have a look on the demo hello world program in JNI, you can find it over
net, and instead of printing the Hello world message just return the process
id, which can be found from the linux API.

please find the article

http://www.pacifier.com/~mmead/jni/cs510ajp/index.html


Thanks & Regards
Anirban Talukdar

On Wed, Dec 2, 2009 at 12:17 PM, raj kumar <bp...@gmail.com> wrote:

> Thanks alot anirban for your help. No i want to get the java process id
> from
> linux only. Can you help me with some script to get the same?
>
> THanks,
> Phani.
>
> On Wed, Dec 2, 2009 at 12:14 PM, Anirban Talukdar <
> talukdar.anirban@gmail.com> wrote:
>
> > In java i don find any API that returns the id of the process. Hopefully,
> > It
> > is because process ID is not standard for all the operating system. I am
> > not
> > sure about this.
> >
> > But in linux you can write a simple C/C++ function to get the process id.
> > And that later can be integrated with java through JNI.
> >
> > If you found direct API in Java, please inform.
> >
> > Thanks & Regards
> > Anirban Talukdar
> >
> > On Wed, Dec 2, 2009 at 12:00 PM, raj kumar <bp...@gmail.com>
> > wrote:
> >
> > > Hi friends,
> > >
> > > When i ran tomcat and shut it down my java process is not closing along
> > > with
> > > shutdown.i need to kill it explicitly. So  I would like to know how to
> > > identify the java process of the logged in user who started the server.
> > so
> > > that i can kill the process id from the shutdown.sh script itself.
> Please
> > > help me.
> > >
> > > Tomcat: jakarta-tomcat-5.0.28
> > > Java : j2sdk1.4.2
> > > OS: SunOS
> > >
> > > Thanks,
> > > Phani.
> > >
> >
>

Re: How to get java process id of a user running tomcat

Posted by raj kumar <bp...@gmail.com>.
Thanks alot anirban for your help. No i want to get the java process id from
linux only. Can you help me with some script to get the same?

THanks,
Phani.

On Wed, Dec 2, 2009 at 12:14 PM, Anirban Talukdar <
talukdar.anirban@gmail.com> wrote:

> In java i don find any API that returns the id of the process. Hopefully,
> It
> is because process ID is not standard for all the operating system. I am
> not
> sure about this.
>
> But in linux you can write a simple C/C++ function to get the process id.
> And that later can be integrated with java through JNI.
>
> If you found direct API in Java, please inform.
>
> Thanks & Regards
> Anirban Talukdar
>
> On Wed, Dec 2, 2009 at 12:00 PM, raj kumar <bp...@gmail.com>
> wrote:
>
> > Hi friends,
> >
> > When i ran tomcat and shut it down my java process is not closing along
> > with
> > shutdown.i need to kill it explicitly. So  I would like to know how to
> > identify the java process of the logged in user who started the server.
> so
> > that i can kill the process id from the shutdown.sh script itself. Please
> > help me.
> >
> > Tomcat: jakarta-tomcat-5.0.28
> > Java : j2sdk1.4.2
> > OS: SunOS
> >
> > Thanks,
> > Phani.
> >
>

Re: How to get java process id of a user running tomcat

Posted by Anirban Talukdar <ta...@gmail.com>.
In java i don find any API that returns the id of the process. Hopefully, It
is because process ID is not standard for all the operating system. I am not
sure about this.

But in linux you can write a simple C/C++ function to get the process id.
And that later can be integrated with java through JNI.

If you found direct API in Java, please inform.

Thanks & Regards
Anirban Talukdar

On Wed, Dec 2, 2009 at 12:00 PM, raj kumar <bp...@gmail.com> wrote:

> Hi friends,
>
> When i ran tomcat and shut it down my java process is not closing along
> with
> shutdown.i need to kill it explicitly. So  I would like to know how to
> identify the java process of the logged in user who started the server. so
> that i can kill the process id from the shutdown.sh script itself. Please
> help me.
>
> Tomcat: jakarta-tomcat-5.0.28
> Java : j2sdk1.4.2
> OS: SunOS
>
> Thanks,
> Phani.
>