From 5971de4590514390beca781ae1a56031ca5b4d3c Mon Sep 17 00:00:00 2001 From: Daniel Ziegenberg Date: Thu, 17 Feb 2022 19:54:41 +0100 Subject: [PATCH] MDL-73923 tool_task: make a more relaxed check on cron run interval Prior to this change, the tool_task_cronrunning check had very tight limits for checking the last cron interval and comparing it to the expected frequency. When a cron job should take 1:00 min and the last run was 1:02 min it complained that there was 1:02 between the last two runs of the cron maintenance script and it should run every 1:00. This change makes the check a bit more relaxed and adds an additional minute on top of the expectedfrequency to give the cron job some time. Signed-off-by: Daniel Ziegenberg --- admin/tool/task/classes/check/cronrunning.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/admin/tool/task/classes/check/cronrunning.php b/admin/tool/task/classes/check/cronrunning.php index 2efcee17950..69596c1733b 100644 --- a/admin/tool/task/classes/check/cronrunning.php +++ b/admin/tool/task/classes/check/cronrunning.php @@ -108,7 +108,8 @@ class cronrunning extends check { return new result($status, $summary, $details); } - if ($lastcroninterval > $expectedfrequency) { + // Add MINSECS to avoid spurious warning if cron is only a few seconds overdue. + if ($lastcroninterval > $expectedfrequency + MINSECS) { $status = result::WARNING; $summary = get_string('croninfrequent', 'admin', [ 'actual' => $formatinterval,