Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am using Monit 5.3.2 in my Linux box. I am monitoring some services using Monit. I want to run a script before the running the restart command. I have used the below conditions for the same.

if does not exist for 2 times within 3 cycles then exec  "/bin/bash -c 'touch /tmp/somefile'" as uid someuser and gid someuser

if does not exist for 10 cycles then restart

Unfortunately only the restart action is getting executed.

Can anyone please help me to identify why the first rule is not executed ? Is there are any other way to solve the problem ?

share|improve this question

1 Answer 1

This is not a definitive answer, as I am a newbie currently chasing down a similar problem.

I currently have a suspicion that the last rule overrides all previous rules.

If so, try:

if does not exist for 2 times within 3 cycles 
then exec  "/bin/bash -c 'touch /tmp/somefile'" as uid someuser and gid someuser 
ELSE if does not exist for 10 cycles then restart
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.