Skip navigation


6 core.php hook_cron()
7 system.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


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

Related topics

17 functions implement hook_cron()

1 invocation of hook_cron()


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


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

  while ($site = db_fetch_array($result)) {