I introduced a heartbeat monitoring system on all my websites late last year. The system involves using a wp-cron
action to send a GET request to an API hosted by Better Uptime, triggered by crontab
command (wp cron event run --due-now;
) every thirty minutes. This works flawlessly on all my websites, except one where every week at exactly 20:30 GMT the heartbeat fails. I have been investigating this.
You can see the pattern for yourself here: https://status.paragondrones.co.uk (open the ‘heartbeat’ section).
Firstly, I checked with Better Uptime. They confirmed that they never received the relevant heartbeats.
Secondly, I checked the wp-cron
action timing (a known issue). That was fine.
Thirdly, I checked whether the Termly plugin was the cause (another known problem). It wasn't.
Turning my focus then to Wordpress, and after some lengthy troubleshooting, I discovered that:
- In 60% of cases, there was no
crontab
log. Probably because Wordpress was too busy to process thecrontab
command. - In 40% of cases, a
crontab
log existed but the heartbeat action was missing from it. Probably because Wordpress was too busy processing scripts because … - In 100% of cases, the
wp-cron
actionwp_site_health_scheduled_check
preceded the failure.
Note: the wp_site_health_scheduled_check
action is a standard feature of Wordpress since v5.2.0, one of only two wp-cron
actions scheduled to run once per week.
My initial thoughts were that the wp_site_health_scheduled_check
script was timing out or trying to utilise too many server resources e.g. RAM, but comparing PHP Variables across three of my websites resulted in no discrepancies – all values were identical. Specifically, max_execution_time
, and max_input_time
were the same and set to a relatively generous 120 seconds, and memory_limit
was set to a generous 768M.
Of course, I could just disable the wp_site_health_scheduled_check
action, but this only fixes the issue, not the underlying problem.
I am at a loss now as to what to do or try next.
- I could try disabling the action, just to prove that it is the root cause, but that doesn’t fix anything.
- Is there a way to log what
wp_site_health_scheduled_check
is doing, find out how long it is taking to execute? - Should I just arbitrarily increase the PHP limits to see whether that helps?
- SiteGround, my hosting provider, has two ‘configurations’ of PHP, either ‘Standard’ or ‘Ultra Fast’. I’m not sure what the differences are but is it worthwhile downgrading to ‘Standard’ to see what happens?
This is beyond my knowledge. Any advice/guidance would be warmly received.
David.