wp-cron is WordPress’ version of a cron job and a cron job is a task that is run on a schedule, whether just once at a particular date and time or on a recurring basis, like every day at 3pm, or every hour on the 15th minute.

Traditional Linux cron jobs run at precisely the time and date they are configured to run, much like the Task Scheduler function in Windows. However in most hosting environments WordPress doesn’t have full system access to be able to add itself to the operating system’s cron jobs, which is necessary for tasks to trigger at exactly their configured date and time.

To work around this, WordPress uses a best-effort (‘as close as we can get’) approach to scheduling tasks. Whenever a visitor views a non-server-cached page on the website (such as every admin page, or the WooCommerce cart), WordPress checks to see if it needs to run something in wp-cron and, if so, it proceeds to run through those scheduled tasks in the background and serves up the normal page that was requested as well.

WooCommerce Scheduled Events

If you are using WooCommerce, it also has its own scheduled events queue, but it does rely upon wp-cron to function.

WooCommerce has an excellent guide to troubleshooting wp-cron (whether you’re using WooCommerce or not) here. We strongly recommend checking it out if you think you’re having trouble with wp-cron.

Setting up wp-cron as a real cron job with Plesk

Time needed: 5 minutes.

If you suspect you’re having problems with a cron task, it can be very beneficial to disconnect normal page views, like people adding things to their cart or checking out with WooCommerce, from wp-cron running, as you don’t want the scheduled tasks to interfere with your checkout process.

Here’s how to do that on our Plesk hosting:

  1. Disable auto-triggered wp-cron

    To disable automatic triggering of the WordPress cron job, open the wp-config.php file in the root of your WordPress installation. You can modify the wp-config.php file via FTP, or Plesk File Manager. Locate define('DB_COLLATE', ''); Right under it, add the following on a line of its own: define('DISABLE_WP_CRON', true);

  2. Set up a Scheduled Task in Plesk

    Log in to Plesk and choose Websites & Domains > Scheduled Tasks > Add Task. Choose the option to Fetch a URL and enter the URL as: https://yourdomain.com/wp-cron.php
    Set your schedule to run hourly (on a VPS you may enter a much more frequent schedule, however on shared hosting a very frequent scheduled task will likely be auto-terminated at some point in the near future).

Source: Plesk Customer Documentation

About Jordan Schelew

Jordan has been working with computers, security, and network systems since the 90s and is a managing partner at Websavers Inc. As a founder of the company, he's been in the web tech space for over 15 years.

Leave a Comment