4

I've installed Drupal 8.1.6. As Ultimate_Cron won't work on this site consistently or reliably, I've decided to just use Drupal's core cron, triggered externally (via /etc/crontab) rather than using Poormanscron.

The documentation on https://www.drupal.org/cron says:

Disabling "automated cron"

Another way to disable cron is to add the following line to your settings.php: $conf['cron_safe_threshold'] = 0; Note that this fixes the setting at admin/config/system/cron to "Never", and administrative users cannot override it.

I set $conf['cron_safe_threshold'] = 0; in the settings.php file, but when I go to admin/config/system/cron, I still see the following:

Cron settings
Run cron every 3 Hours

What does fixes the setting at admin/config/system/cron to "Never" actually mean?

  1. The value I see is set to "Never", and can't be changed

  2. The value is overwritten in the {variables} table to a fixed value equal to 0, and that the displayed drop-down value on admin/config/system/cron is irrelevant

p.s.

There's gotta be an easier way to find out available $conf settings than this

1) realize that cron in Drupal8 is actually controlled by a core module

cd web/core/modules/automated_cron

2) look for any drupal::config() assignments

grep -i "drupal::config(" *.module
    $automated_cron_settings = \Drupal::config('automated_cron.settings');

3) for each one found, get set-able vars

grep -i "automated_cron_settings" *.module | grep "=>"
    '#default_value' => $automated_cron_settings->get('interval'),

NOTE: in default.settings.php

 * Example:
 * @code
 *   $conf1) realize that cron in Drupal8 is actually controlled by a core module

     cd web/core/modules/automated_cron

     2) look for any drupal::config() assignments

         grep -i "drupal::config(" *.module
                 $automated_cron_settings = \Drupal::config('automated_cron.settings');

                 3) for each one found, get set-able vars
                     grep -i "automated_cron_settings" *.module | grep "=>"
                             '#default_value' => $automated_cron_settings->get('interval'),
                             ig_directories = array(
 *     CONFIG_SYNC_DIRECTORY => '/directory/outside/webroot',
 *   );
 * @endcode
 */

Re: automated cron, no less

and, a 'simpler' method:

drush cli | grep -i cron
    automated_cron.settings
    system.cron

drush cget automated_cron.settings
    interval: 10800                                                                              
    ...

drush cget system.cron       
    threshold:                                                                                   
      requirements_warning: 172800                                                               
      requirements_error: 1209600                                              
    ...
5

This setting is for Drupal 7. In Drupal 8, the equivalent is in the config management system as automated_cron.settings.interval. To override it, like in Drupal 7, you can add:

$config['automated_cron.settings']['interval'] = 0;

to your settings.php.

To address the other question, the relevance of automated_cron.settings.interval & cron_safe_threshold is the minimum amount of time (in seconds) since the last cron run that Drupal is allowed to run again. This value is checked (D7 & D8) for a 0 threshold which it will interpret as FALSE and thus never run cron.

  • That does it -- I now see 'Never' autoselected in the dropdown. I see you corrected the Drupal doc page, too. Thx. – user58258 Jul 16 '16 at 14:38
  • p.s. Where did you find that parameter/form in general for D8 vs D7? I obviously didn't find it. – user58258 Jul 16 '16 at 14:44
  • The variable table has been replaced with the config table as a part of D8's config management system. The name keys should give you an idea of what each entry is for. – Shawn Conn Jul 16 '16 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.