MDL-64454 Admin: Warning if cron does not run frequently

There is an existing warning if cron doesn't run at all (hasn't run
for 24 hours). This commit adds a warning if cron hasn't run for 3
minutes, based on the recommendation that cron should run every
minute.
This commit is contained in:
sam marshall 2018-12-20 11:08:15 +00:00
parent 4c5b60a0f9
commit b18034ed67
4 changed files with 31 additions and 4 deletions

View file

@ -61,6 +61,14 @@ function cron_run() {
$timenow = time();
mtrace("Server Time: ".date('r', $timenow)."\n\n");
// Record start time and interval between the last cron runs.
$laststart = get_config('tool_task', 'lastcronstart');
set_config('lastcronstart', $timenow, 'tool_task');
if ($laststart) {
// Record the interval between last two runs (always store at least 1 second).
set_config('lastcroninterval', max(1, $timenow - $laststart), 'tool_task');
}
// Run all scheduled tasks.
while (!\core\task\manager::static_caches_cleared_since($timenow) &&
$task = \core\task\manager::get_next_scheduled_task($timenow)) {