当我尝试使用monit的"检查程序"检查bash脚本的退出状态时,我收到语法错误.如果我手动运行bash脚本,则不会出错.但是如果我在配置中使用我的monit check程序进行monit reload,monit会给我错误.
这是我目前的monit .conf文件 -
check program myscript with path "/etc/monit.d/script_to_run.sh"
if status != 0 then alert
Run Code Online (Sandbox Code Playgroud)
如果我将其更改为此以确保monit使用bash来解析文件...
check program myscript with path "/usr/bash /etc/monit.d/script_to_run.sh"
if status != 0 then alert
Run Code Online (Sandbox Code Playgroud)
然后我得到这个错误
Warning: Program does not exist: '"/bin/bash /etc/monit.d/script_to_run.sh"'
Run Code Online (Sandbox Code Playgroud)
即使是测试脚本也会导致错误 - 如果我在script_to_run.sh中有这个:
#!/bin/bash
exit 0
Run Code Online (Sandbox Code Playgroud)
莫妮特会抱怨
Error: syntax error 'exit'
Run Code Online (Sandbox Code Playgroud)
如果我在script_to_run.sh中有这个:
#!/bin/bash
echo "hello"
Run Code Online (Sandbox Code Playgroud)
莫妮特会抱怨
Error: syntax error 'echo'
Run Code Online (Sandbox Code Playgroud)
作为参考 - 我有monit 5.4,已经按照man monit doc中的"check program"示例,并且能够在同一台服务器上配置/使用monit"check process ...".
monit ×1