// Don't call handle_exception; try to update next run time and free the lock } $nextrun = cron_next_run_time($start, (array) $job); // update next run time set_field($plugintype . '_cron', 'nextrun', db_format_timestamp($nextrun), 'plugin', $job->plugin, 'callfunction', $job->callfunction); cron_free($job, $start, $plugintype); $now = $fake ? time() - ($realstart - $start) : time(); } } } // and now the core ones (much simpler) $now = $fake ? time() - ($realstart - $start) : time(); $jobs = get_records_select_array('cron', 'nextrun < ? OR nextrun IS NULL', array(db_format_timestamp($now)), '', 'id,callfunction,minute,hour,day,month,dayofweek,' . db_format_tsfield('nextrun')); if ($jobs) { foreach ($jobs as $job) { if (!cron_lock($job, $start)) { continue; } // If some other cron instance ran the job while we were messing around, // skip it. $nextrun = get_field_sql(' SELECT ' . db_format_tsfield('nextrun') . ' FROM {cron} WHERE id = ?', array($job->id)); if ($nextrun != $job->nextrun) { log_info("Too late to run core {$job->callfunction}; skipping."); cron_free($job, $start); continue; } log_info("Running core cron " . $job->callfunction); $function = $job->callfunction;
/** * called by cli/cron_daily.php */ function cron_daily() { while (!cron_lock()) { echo "Waiting for lock ...\n"; sleep(5); } update_supporters_cache(); revoke_not_enough_proponents(); cancel_not_admitted(); clear_issues(); update_activity(); cron_unlock(); }