如何检查 JBoss 是否在 Unix 服务器上运行? [英] How to check if JBoss is running on Unix server?
本文介绍了如何检查 JBoss 是否在 Unix 服务器上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我下面有一个脚本,我想根据它是否可以在进程列表中找到 jboss 进程来回显jboss not running"或jboss is running".但是,当我关闭 Jboss 时,它仍会执行 Else 条件并显示jboss 正在运行".如果我手动执行pgrep -f jboss",它不会返回任何内容,那么为什么它仍会进入 Else 状态?困惑
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
感谢您的帮助!
推荐答案
不要检查输出,只需使用命令:
Instead of checking the output, just use the command:
if pgrep -f jboss >/dev/null
then
echo "jboss is running"
else
echo "jboss is not running"
fi
这篇关于如何检查 JBoss 是否在 Unix 服务器上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文