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
    #1  
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:

run('some_linux_command')

What should be 'some_linux_comand' be here?

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

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

Any idea?
Sponsored Links
    #2  
Old 08-24-2010
verdepollo's Avatar
verdepollo verdepollo is offline
Registered User
 
Join Date: Mar 2010
Last Activity: 24 June 2014, 4:41 PM EDT
Location: Mexico
Posts: 725
Thanks: 11
Thanked 105 Times in 101 Posts

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

Sponsored Links
    #3  
Old 08-24-2010
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
Moderator
 
Join Date: Jan 2007
Last Activity: 24 July 2014, 9:57 AM EDT
Location: Варна, България / Milano, Italia
Posts: 5,663
Thanks: 182
Thanked 616 Times in 574 Posts

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

    #4  
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:

Quote:
[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 -Dprogram.name=run.sh -server -Xms512m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -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/run.sh -c comp
root 530 507 8 16:44 ? 00:00:57 /comp/java/bin/java -Dprogram.name=run.sh -server -Xms512m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -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?


Thanks,
Peter
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 12:53 PM
Installing jboss on aix manoj.solaris AIX 1 05-22-2009 12:47 PM
Creating startup service for JBoss vpatil6688 AIX 0 11-01-2008 02:56 AM
JBoss Application Server 5 CR1 available Linux Bot Red Hat 0 09-11-2008 10:07 AM



All times are GMT -4. The time now is 01:15 AM.