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!
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.
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.
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.
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/.
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With