Home Articles Platform info Drupal How to setup Drupal Cron Jobs

How to setup Drupal Cron Jobs

To improve performance in Drupal, we recommend disabling the built-in cron system in Drupal and run cron on the server side instead. This will offload the website and may cause significant improvements to the TTFB (Time to first Byte).

Time needed: 2 minutes.

Here’s how to setup cron the right way with Drupal.

  1. Disable Drupal built-in cron system

    Edit the settings.php file for your Drupal website and add the following line:

    $conf['cron_safe_threshold'] = 0;

  2. Setup cron in our control panel

    Go to the settings page for your website in our control panel. Enter the following in the field for time:

    */10 * * * *

    This will make the cron job run once every 10 minutes. In the command field, enter this command:

    drush --root=/kunder/group/user/public/ --uri=yourdomain.com --quiet cron

    Note: you need to replace the root-paramenter with the complete path to your folder and the uri-parameter with your domain name. You can find this in the site settings inside your Servebolt Control Panel.

    Click the “Add” button and the cron job will be saved.

  3. Configure email notifications

    If you don’t want to receive emails when your cron jobs have been executed, select the (newly created) cron job in the list of this page and, in the drop-down box below, select “Do not send email”. Click the “Update” button in the bottom of the page.

You may still receive email messages regarding cron jobs if an error occurred during the execution of the cron. To get rid of these emails, you will need to fix the code that is related to the errors.

Did this help you?