// We usually don't want to act every time cron runs (which could be every
// minute) so keep a time for the next run in a variable.
if (time() >= config_get('cron_example.settings', 'cron_example_next_execution')) {
// This is a silly example of a cron job.
// It just makes it obvious that the job has run without
// making any changes to your database.
watchdog('cron_example', 'cron_example ran');
if (!empty($GLOBALS['cron_example_show_status_message'])) {
backdrop_set_message(t('cron_example executed at %time', array('%time' => cron_example_date_iso8601(time(0)))));
}
config_set('cron_example.settings', 'cron_example_next_execution', time() + $interval);
}
The next time a cron hook should be executed is not a value to put in a configuration file, for the same reason the time backdrop_cron_run() has been called is set with state_set('cron_last', REQUEST_TIME).
cron_example_cron()
uses the following code.The next time a cron hook should be executed is not a value to put in a configuration file, for the same reason the time
backdrop_cron_run()
has been called is set withstate_set('cron_last', REQUEST_TIME)
.