Running Automation via Cron Job

Entry Automation runs scheduled automation actions through WordPress’ task scheduler, via a file named wp-cron.php.

By default, wp-cron.php runs on every page load, checking to see if there are any scheduled actions waiting to be run.

Due to how long Entry Automation tasks can take to run, this can cause performance issues for your users. Additionally, because it only runs on every page load, automation actions might not occur exactly on the scheduled times if your site has lower/inconsistent traffic in general, aggressive caching solutions implemented, or has regular periods of lower traffic (i.e. overnight) as many sites will.

Due to this, depending on your setup, you may see your tasks not running reliably or their run times slowly creeping up over time with each subsequent runtime.

We can solve this problem by disabling wp-cron.php and running it automatically via the server’s crontab. This will make sure we’re checking for tasks to run at a set regular interval, rather than relying on the site receiving traffic around the time the task is supposed to run.

Disabling wp-cron.php

Disabling wp-cron.php is as simple as adding one line to your site’s wp-config.php editor.

  1. Open your wp-config.php file in your text editor of choice.
  2. Navigate to the area following the database definitions.
  3. Add the following line:
    define( 'DISABLE_WP_CRON', true );
  4. Save the file and upload it to your site.

Adding a cron job

We now need to add a cron job to the server’s crontab to run wp-cron.php once every five minutes.

You can change the interval to run as often as you’d like, keep in mind that the interval you set now becomes your floor as to how frequently scheduled tasks can run, e.g. if you set the interval to an hour, you can now only schedule tasks to run as frequently as every hour at a minimum.

Tasks can still be set to run more frequently via the UI than the interval set on the cron job, however those tasks will remain queued up until the next time the cron job fires at the specified interval.

Server Administrators

If you run your own server, here are some steps for adding a cron job:

  1. Start the crontab editor:
    crontab -e
  2. Add a cron job for wp-cron.php:
    */5 * * * * curl http://example.com/wp-cron.php?doing_wp_cron > /dev/null 2>&1

This cron job will run the wp-cron.php every five minutes and not capture the output of the script. You’ll want to replace example.com with the URL of your WordPress site.

Hosting Control Panel

If you have access to a control panel to control your web hosting account, there are guides available for how to add a cron job for the control panel you’re using.

When setting up a cron job via a hosting control panel, you will want to ensure that:

  1. The cron job is set to run every five minutes.
  2. The cron job runs the following command:
    */5 * * * * curl https://example.com/wp-cron.php?doing_wp_cron > /dev/null 2>&1

    You’ll want to replace example.com with the URL of your WordPress site.

Here are guides for how to add a cron job for the most popular hosting control panels: