Is it possible to configure
monit to restart an application periodically? I'm using
monit to check the application health and restart it if it has died. I also want to periodically restart it. Prefer to do it with
monit rather than having a
cron job separately.
I don't feel like this is the right way to use
monit. Anyway, you can try the following snippet of configuration:
check process dummy with pidfile /var/lib/dummy.pid start program = "/path/to/restart/script.sh" with timeout 60 seconds
Here, we just define any dummy process that does not exist. Every time monit will check it, it will fail to start and so the script is executed. This way you will get the restart script executed every time monit checks the service plus the timeout.
If monit is configured to check services every 2 minutes, you will get the script executed every 2 + 1 (timeout 60 seconds) = 3 minutes.
I prefer a simple cron job to do it, but this is to answer your question.