Knowledge Base

How to Replace WP-Cron With a Linux Cron Job

Linux Cron Job vs. WP-Cron

Have you ever noticed that your scheduled posts in WordPress are missing? Though WordPress has its own cron feature that dictates the scheduling of your blog’s posts and events, WP-cron is not a literal cron job.

Linux cron jobs can be controlled by the user, making certain that the items constrained by schedule are run appropriately. Also, for a high-traffic WordPress site, a Linux cron job can assist with reducing the chances of downtime by lowering the bandwidth on the server, thus using less server resources.

WP-cron is a virtual cron that only works when the page is loaded. WP-cron is first loaded by WordPress when a page is requested on the front or backend of a site at which point WP-cron displays the necessary page to the site visitor.

How to Replace WP-Cron With a Linux Cron Job

The best way to optimize the efficiency of your WordPress cron jobs is to disable WP-cron and set up a normal cron job through cPanel which will run every hour.

  1. Disable wp-cron.php
    You can disable WP-cron by modifying the wp-config.php (located in the folder where WordPress is installed). Open the wp-config.php file, add a new line after <?php, then add the following code on the new line:
    define('DISABLE_WP_CRON', true);
  2. Disable wp-cron.php
  3. To set up a Linux cron job:
    • Log into your cPanel.
    • In the Advanced section, click Cron jobs.
    • Under Add New Cron Job, select the time interval. We recommends that you do not set the interval lower than 15 minutes.
    • Set the cron command to the following, replacing yourwebsite.com with your actual domain name:
      wget -q -O - http://yourwebsite.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1
    • Click Add New Cron Job to set the cron.
    In order to test out the new cron, simply wait for the elapsed time period for the cron to run. In the event that the cron does not run, please review the steps listed above to ensure that you have completed all steps correctly.

Last Updated: 10/07/2019 01:36

A total of 1 / 1 users found this article useful.

Did you find this article useful? Yes | No