function system_cron

Implements hook_cron().

Remove older rows from flood and batch table. Remove old temporary files.

File

drupal/core/modules/system/system.module, line 3441
Configuration system that lets administrators modify the workings of the site.

Code

function system_cron() {

  // Cleanup the flood.
  Drupal::service('flood')
    ->garbageCollection();
  module_invoke_all('cache_flush');
  foreach (Cache::getBins() as $cache_backend) {
    $cache_backend
      ->garbageCollection();
  }

  // Cleanup the queue for failed batches.
  db_delete('queue')
    ->condition('created', REQUEST_TIME - 864000, '<')
    ->condition('name', 'drupal_batch:%', 'LIKE')
    ->execute();

  // Reset expired items in the default queue implementation table. If that's
  // not used, this will simply be a no-op.
  db_update('queue')
    ->fields(array(
    'expire' => 0,
  ))
    ->condition('expire', 0, '<>')
    ->condition('expire', REQUEST_TIME, '<')
    ->execute();
}