1. Documentation
  2. Entry Automation
  3. Running Automation via Cron Job

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 on the scheduled times in your automation configurations.

We can solve this problem by disabling wp-cron.php and running it automatically via the server’s crontab.

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 );
  1. 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. ForGravity recommends not setting the interval to above fifteen minutes as automation actions are set to run every quarter-hour.

Server Administrators

If you run your own server, adding the cron job is very simple.

  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 http://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:

Was this article helpful to you? Yes 1 No