How to get jboss pid? | Unix Linux Forums | Red Hat

  Go Back    

Red Hat Red Hat is the world's leading open source technology solutions provider with offerings including Red Hat Enterprise Linux (RHEL), Fedora, open source applications, security and systems management, virtualization, and Services Oriented Architecture (SOA) solutions.

How to get jboss pid?

Red Hat

Closed Thread    
Thread Tools Search this Thread Display Modes
Old 08-23-2010
pbsdis pbsdis is offline
Registered User
Join Date: Aug 2010
Last Activity: 26 August 2010, 5:19 PM EDT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
How to get jboss pid?

I am writing SSH (actually Python via SSH) commandline to get jboss PID from a remote machine (Redhat), how can I do it?

I usually have the patten like:


What should be 'some_linux_comand' be here?

I also tried a shell script (I found in internet) local on the machine

PID=$(ps -eo pid,comm | awk '$2=="jboss" {print $2}')
echo $PID
if [ -z "$PID"]; then
echo No Jboss running
echo All done
But it return nothing, while I used 'ps -ef | grep jboss' returned information with the PID.

Any idea?
Sponsored Links
Old 08-24-2010
verdepollo's Avatar
verdepollo verdepollo is offline
Registered User
Join Date: Mar 2010
Last Activity: 2 January 2015, 8:32 PM EST
Location: Mexico
Posts: 725
Thanks: 11
Thanked 106 Times in 102 Posts

PID=$(ps -ef | awk '/jbos[s]/ {print $2}')

Sponsored Links
Old 08-24-2010
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
Join Date: Jan 2007
Last Activity: 25 February 2015, 10:24 AM EST
Location: Варна, България / Milano, Italia
Posts: 5,678
Thanks: 184
Thanked 623 Times in 581 Posts

ssh <user>@<remote_host> 'pgrep -f jboss'

Old 08-26-2010
pbsdis pbsdis is offline
Registered User
Join Date: Aug 2010
Last Activity: 26 August 2010, 5:19 PM EDT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you guys for your help. It works now!

---------- Post updated at 04:09 PM ---------- Previous update was at 11:51 AM ----------

Woops, I guess I should have tried more before I replied.

Now I have issues -

The command I used ps -ef | awk '/jbos[s]/ {print $2} some time return one number which is correct and I can kill the process using the number - that's what happened when I replied; but later I found that it sometime returned two numbers, the first one is not the right one so my program trying to kill the process failed and quit.

Then I logged on the remote machine and tried to get the jboss (ps -ef | grep jboss), I did see the output:

[SERVER /]$ ps -ef | grep jboss
usr_name 364 31548 0 16:44 pts/0 00:00:00 grep jboss
root 32261 1 12 16:35 ? 00:01:04 /comp/java/bin/java -server -Xms512m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=256m -Djava.endorsed.dirs=/apps/tparty/jboss/inuse/lib/endorsed -classpath /apps/tparty/jboss/inuse/bin/run.jar:/comp/java/lib/tools.jar org.jboss.Main -c comp

[SERVER /]$ ps -ef | grep jboss
root 507 1 0 16:44 ? 00:00:00 /bin/sh /apps/tparty/jboss/inuse/bin/ -c comp
root 530 507 8 16:44 ? 00:00:57 /comp/java/bin/java -server -Xms512m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=256m -Djava.endorsed.dirs=/apps/tparty/jboss/inuse/lib/endorsed -classpath /apps/tparty/jboss/inuse/bin/run.jar:/comp/java/lib/tools.jar org.jboss.Main -c comp
usr_name 952 31548 0 16:55 pts/0 00:00:00 grep jboss
You can see that my program returned the right number (32261) in the first trial, but after jboss was restarted, the second run of my program failed because it returned 507 and 530 (530 is the right one but program failed trying to kill 507 first).

I am new Linux user and would like to know why is that, and how can I modify my program (or the command) to make it always work?

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script to monitor JBoss web server nsachin Shell Programming and Scripting 2 11-13-2009 01:53 PM
Installing jboss on aix manoj.solaris AIX 1 05-22-2009 01:47 PM
Creating startup service for JBoss vpatil6688 AIX 0 11-01-2008 03:56 AM
JBoss Application Server 5 CR1 available Linux Bot Red Hat 0 09-11-2008 11:07 AM

All times are GMT -4. The time now is 12:41 AM.