Same name and namespace in other branches
  1. 10 core/core.api.php \hook_cron()
  2. 4.6.x developer/hooks/core.php \hook_cron()
  3. 4.7.x developer/hooks/core.php \hook_cron()
  4. 6.x developer/hooks/core.php \hook_cron()
  5. 7.x modules/system/system.api.php \hook_cron()
  6. 8.9.x core/core.api.php \hook_cron()
  7. 9 core/core.api.php \hook_cron()

Perform periodic actions.

Modules that require to schedule some commands to be executed at regular intervals can implement hook_cron(). The engine will then call the hook at the appropriate intervals defined by the administrator. This interface is particularly handy to implement timers or to automate certain tasks. Database maintenance, recalculation of settings or parameters, and automatic mailings are good candidates for cron tasks.

Return value

None.

This hook will only be called if cron.php is run (e.g. by crontab).

Related topics

10 functions implement hook_cron()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

aggregator_cron in modules/aggregator/aggregator.module
Implementation of hook_cron().
drupal_cron in modules/drupal/drupal.module
Implementation of hook_cron(); handles pings to and from the site.
filter_cron in modules/filter/filter.module
Implementation of hook_cron().
node_cron in modules/node/node.module
Implementation of hook_cron().
ping_cron in modules/ping/ping.module
Implementation of hook_cron().

... See full list

File

developer/hooks/core.php, line 152
These are the hooks that are invoked by the Drupal core.

Code

function hook_cron() {
  $result = db_query('SELECT * FROM {site} WHERE checked = 0 OR checked
    + refresh < %d', time());
  while ($site = db_fetch_array($result)) {
    cloud_update($site);
  }
}