How to run a shell script before restarting a service in Monit in case of a crash
Posted
by
Supratik
on Server Fault
See other posts from Server Fault
or by Supratik
Published on 2012-08-23T13:33:20Z
Indexed on
2012/08/30
3:40 UTC
Read the original article
Hit count: 459
monit
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 ?
© Server Fault or respective owner