问题
Monit is currently executing once. I can see in the log file that it does a check every cycle, however, the execution only happens once when I reload monit.
check host somehost with address example.com
# every "* 8-19 * * 1-5"
if failed
port 443
protocol https
and certificate valid > 1095 days
then exec "/var/local/bin/mtCert.sh"
回答1:
Monit is based on triggers
, it basically only tracks changes.
So if the configured state is not changing, monit will not trigger the script again by default. See note on 5.16.0 at Monit Changelog:
Fixed: The exec action is now executed only once on state change, the same way as the alert action. The new repeat option can be used to repeat the exec action after a given number of cycles if the error persists. Syntax:
if <test> then exec <script> [repeat every [x] cycle(s)]
If you want the old behaviour, use "repeat every cycle". Example:
if failed port 1234 then exec "/usr/bin/myscript.sh" repeat every cycle
So if you in fact need the script to be called multiple times, just add the repeat
:
check host somehost with address example.com
# every "* 8-19 * * 1-5"
if failed
port 443
protocol https
and certificate valid > 1095 days
then exec "/var/local/bin/mtCert.sh"
and repeat every 10 cycles
来源:https://stackoverflow.com/questions/56011030/monit-only-executing-once