简体   繁体   English

使用bash检查linux应用程序状态,并在不起作用时发出警报

[英]Check linux app status using bash and alert if its not working

Hi guys the problem is pretty simple I just don't know how to solve this in bash. 大家好,问题很简单,我只是不知道该如何解决bash。 I want to write simple mule server status checker. 我想编写简单的m子服务器状态检查器。 I can check it using command: 我可以使用命令检查它:

./mule status

Then I receive to possible communicates: 然后我收到可能的通讯:

If all ok: 如果一切正常:

MULE_HOME is set to /home/mule/mule
Mule is running (3496).

And if not ok: 如果还不行:

MULE_HOME is set to /home/mule/mule
Mule is not running.

How can I catch this communicates and for example do simple if / else with - eq 我如何才能捕捉到这种交流,例如使用-eq做简单的if / else

The standard for that is using exitcodes, like all standard executable do. 就像所有标准可执行文件一样,其标准是使用退出代码。 The program needs to use "exit" (without quotes) with some value. 该程序需要使用具有某些值的“退出”(不带引号)。 The receiver needs to evaluate "$?" 接收者需要评估“ $?” (without quotes) (无引号)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM