Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if JBoss is running on Unix server?

I have a script below that I'd like to echo out "jboss not running" or "jboss is running" depending on whether it can find the jboss process in the process list. However, when I shut down Jboss it still executes the Else condition and says "jboss is running". If I manually do "pgrep -f jboss" it doesn't return anything, so why is it still going into the Else condition? puzzled

#!/bin/bash
if [ -z "$(pgrep -f jboss)" ]
  then
  echo "jboss is not running"
else
  echo "jboss is running"
fi 

Thanks for your help!

like image 618
user1060096 Avatar asked Jan 06 '12 16:01

user1060096


People also ask

How do I know if JBoss is running on Linux?

To test your installation, open the JBOSS_DIST/jboss-<release>/bin directory and execute the run. bat (for Windows) or run.sh (for Linux) script, as appropriate for your operating system.

How do I know if JBoss is starting?

Run jps, grep it for the line with you jboss, cut the PID from the line and check the PID. Show activity on this post. Show activity on this post.

How do I find my JBoss server?

Starting the server and checking the status However, the jps command line is available upon JDK installation. Therefore, you can use the jps command to check the server status. When the server stops, the startup-marker file will be removed.

What is the command to check JBoss?

When the JBoss Enterprise Application Platform server is running you can retrieve its version information from the first page of the Web Console. This is located at http://localhost:8080/web-console/.


1 Answers

The best way is use this

result=`$jboss/bin/jboss-cli.sh --connect controller=localhost:$controller_port --commands=\"read-attribute server-state\" > out 2&1`
echo "$result" | grep -q "running"
if [ $? -eq 0 ];then 
   echo "Jboss running"
fi

If you want to check if ear or war file is deployed then you could use the following command

$JBOSS_HOME/bin/jboss\-cli.sh --connect controller=localhost:$PORT  --command="deployment-info --name=$YOUR_WAR_OR_EAR_FILE" 
like image 154
Raghu K Nair Avatar answered Sep 28 '22 22:09

Raghu K Nair