如何检查JBoss是否在Unix服务器上运行? [英] How to check if JBoss is running on Unix server?

查看:381
本文介绍了如何检查JBoss是否在Unix服务器上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面有一个脚本,我想根据在进程列表中是否找到jboss进程来回显"jboss未运行"或"jboss正在运行".但是,当我关闭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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆