Mahara reporting cron is not running

If you are seeing the message “Cron is not running” in the Mahara admin dashboard, here are a few tips to get to the bottom of this.

First, you need some decent logging turned on. If you run lib/cron.php without any logging it won’t tell you anything useful at all. To get this, have a look at the file lib/config-defaults.php at the log targets configuration. You need to take some form of this and put it in your main config.php file for example:

// Set appropriate logging level
$cfg->log_dbg_targets     = LOG_TARGET_ERRORLOG;
$cfg->log_info_targets    = LOG_TARGET_ERRORLOG;
$cfg->log_warn_targets    = LOG_TARGET_ERRORLOG;
$cfg->log_environ_targets = LOG_TARGET_ERRORLOG;

The above will log errors to your standard PHP error log.

Now you can run the cli (php lib/cron.php) and check the appropriate PHP error log file. You might find that some functions are being skipped. To see which ones, have a look for any locked crons in the config table:

select * from config where field like '%cron%';

These are the cron processes that might be blocking the cron completing. Remove the lock by deleting this row.

Finally check the cron table. The Cron not running message is driven by the site_statistics() function in lib/registration.php.

Specifically it runs a query like this to check for any unfinished cron processes:

select * from cron where nextrun IS NULL OR nextrun < CURRENT_DATE;

Check these and take appropriate action.