How to Replace WordPress Cron with a Real Cron Job

How to Replace WordPress Cron with a Real Cron Job

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 job vs. WP-cron

The user can control Linux cron jobs, ensuring that the items constrained by the schedule are run appropriately. Also, for a high-traffic WordPress site, a Linux cron job can reduce the chances of downtime by lowering the bandwidth on the server, thus using fewer 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 site’s front or back end. Though convenient, it is known to fail for a variety of reasons:

Conflict of plugins

DNS-related issues

WordPress bugs

Use of caching plugins

Large server load

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.

If you have multiple WordPress sites, you will need to stagger your cron jobs so they will not run simultaneously. This could potentially cause your site to become restricted.

Step 1: Disable wp-cron.php

You can disable WP-cron by modifying the wp-config.php file, which is located in your WordPress site’s document root.

1. Open the wp-config.php file.

2. Add a new line after <?php.

3. Add the following code on the new line:

define('DISABLE_WP_CRON', true);

Step 2: Set up Linux cron

You need to have a working knowledge of Linux commands before you can use cron jobs effectively.

1. Log in to your cPanel from Twilight I.T.

2. In the Advanced section, click Cron jobs.

3. Under Add New Cron Job, select the time interval. Do not set the interval lower than 15 minutes.

4. 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

5. Click Add New Cron Job to set the cron.

Staggering Multiple WordPress Cron Jobs

Creating cron jobs for multiple WordPress cron without custom configuration can cause them all to fire at the same time. Having multiple cron jobs run simultaneously can cause your CPU usage to increase, negating the benefit of using Linux cron jobs.

To stagger your cron jobs:

1. Divide 60 by the number of WordPress installations you have. If you have more than 60, use the number 1.

2. When creating your WordPress cron jobs, use 0 for minutes for your first cron job.

3. For each cron job after the first one, add the number you got in Step 1.

Note: If you have more than 60 WordPress sites, after you reach 59, you will need to start at 0 again. If you experience CPU issues with this many WordPress sites running cron jobs this frequently, you may wish to consider migrating some of your sites to a second account.

    • Related Articles

    • Running WP-CLI as Root to Import Posts for a cPanel User

      Overview This guide explains how to safely run WP-CLI commands in WHM Terminal as the root user to perform WordPress imports for a specific cPanel account. This method does not require enabling shell access for the cPanel user and ensures that no ...
    • Step-by-Step Guide: Moving a Joomla Website Between cPanel Accounts

      Preparation • Ensure you are authorized to move the site. • In the source cPanel, note the document root (usually public_html). • In Joomla admin, optionally set the site Offline to freeze content during migration. • Verify the PHP version used on ...
    • How to Install a Custom Font in WordPress

      Option 1: Using a Plugin (Easiest Method) If you want to avoid editing theme files, you can use a plugin. Steps: 1. Log in to your WordPress Admin Dashboard. 2. Go to Plugins → Add New Plugin. 3. Search for one of these plugins: – Use Any Font (very ...
    • Setting the Default Blog Archive Page in WordPress (Using Elementor Template Kits)

      If you’re using an Elementor Template Kit, your Blog Archive page (the page that lists your blog posts) may not automatically display correctly until you designate it as the default “Posts Page” in WordPress and apply the correct Elementor template. ...
    • How to Get Google Sitelinks for Your Website

      Google sometimes shows extra sub-links under your website’s main search result. These are called sitelinks, and they help users navigate directly to important pages of your site. You can’t turn them on manually, but you can improve your chances of ...
    • Popular Articles

    • How to install Office Apps (365) to your Windows or Mac computer

      How to Download and Install Microsoft 365 Office Apps (Windows and Mac) This guide will walk you through downloading and installing the Microsoft 365 Office apps, including Word, Excel, PowerPoint, Outlook, and more. The steps are nearly the same for ...
    • How to Save and Share a Document in OneDrive from Word or Excel

      Follow these steps to save your document to OneDrive and share it with others directly from Word or Excel. ————— Step 1: Save to OneDrive 1. In Word or Excel, click File. 2. Select Save As. 3. Choose OneDrive – [Your Organization or Personal]. 4. ...
    • How to Collaborate on a Document in Real-Time with Others

      Microsoft 365 allows you to co-author documents with colleagues in Word, Excel, or PowerPoint. ————— Step 1: Save to OneDrive or SharePoint 1. Open your file in Word, Excel, or PowerPoint. 2. Click File > Save As and select OneDrive or SharePoint. ...
    • How to Recover Unsaved or Previous Versions of Office Files

      If you lose changes or accidentally close a document, you can often recover it using Office’s built-in recovery tools. ————— Step 1: Recover Unsaved Files 1. Open Word, Excel, or PowerPoint. 2. Go to File > Info > Manage Document (or Manage ...
    • How to Use Templates in Word, Excel, and PowerPoint

      Microsoft Office apps come with ready-to-use templates to save you time. ————— Step 1: Access Templates 1. Open Word, Excel, or PowerPoint. 2. From the start screen, you’ll see featured templates. 3. Or click File > New to browse available templates. ...