8.5.x core.api.php hook_cron()
8.0.x core.api.php hook_cron()
8.1.x core.api.php hook_cron()
8.2.x core.api.php hook_cron()
8.3.x core.api.php hook_cron()
8.4.x core.api.php hook_cron()
8.6.x core.api.php hook_cron()
4.6.x core.php hook_cron()
4.7.x core.php hook_cron()
5.x core.php hook_cron()
6.x core.php hook_cron()
7.x 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

8 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.module
Implementation of hook_cron().
drupal_cron in modules/drupal.module
Implementation of hook_cron(); handles pings to and from the site.
node_cron in modules/node.module
Implementation of hook_cron().
ping_cron in modules/ping.module
Implementation of hook_cron().
poll_cron in modules/poll.module
Implementation of hook_cron().

... See full list

1 invocation of hook_cron()


developer/hooks/core.php, line 259
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)) {