Question

So I have couple of things to make sure crons are running ok.

  1. Protection against stacking -> flock (manual)
  2. Monitoring cron availability -> https://healthchecks.io/
  3. Prevent "hanging" cronjobs -> ?

The problem: Cronjobs are protected from stacking with flock. It creates a lock with a lock file. But when a cronjob hangs or just doesn't finish for whatever reason the lock never expires. And with this the cronjob never runs again unit the lock file is manually removed

Question: How can I solve the issue of hanging cronjobs and never starting again because of the infinite lock?

I tried to just put timeout 3600 in the cron command without any luck.

No correct solution

OTHER TIPS

An idea would be to install a tool like Supervisor and use it to keep a custom script always up and running. In this custom script (maybe bash?) you could check the running time that a process identifiable as a magento cron process is displaying. If it's greater than a custom value that you define, then kill the process.

The restarting part I think it's something that has to do with the Magento cronjob schedule and should not necessarily be commanded from the outside, otherwise you lose the whole point of having cronjob scheduling in Magento.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top