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 add your Microsoft 365 Email on an iPhone using the Outlook app

      How to Set Up Microsoft 365 Email on Your iPhone Using Outlook This guide will walk you through downloading the Outlook app and adding your Microsoft 365 email account on your iPhone. ————— Step 1: Download the Outlook App 1. Open the App Store on ...
    • Outlook Error "5objp" when setting up email on Outlook App

      Follow these steps if you are having trouble signing into Outlook with your Microsoft 365 account: ————— Step 1: Start with the onmicrosoft.com Address • First, try signing in using the @myorg.onmicrosoft.com format email address. – Example: ...
    • How to update your credit card on file

      Do you need to update your credit card on file within the Twilight I.T. Customer Portal? Here is what you need to do... Step 1: Log into the portal at https://portal.twilightit.com Step 2: Click on BILLING in the top menu. Step 3: Click on PAYMENT ...
    • How to view or download invoices on your account

      Here is the process of viewing and/or downloading invoices on your account with Twilight I.T. Step 1: Log into the client portal at https://portal.twilightit.com Step 2: Click on the BILLING menu Step 3: From here you can view all your invoices. If ...
    • How to add your Microsoft 365 Email on an Android phone using the Outlook app

      How to Set Up Microsoft 365 Email on Your Android Phone Using Outlook This guide will walk you through downloading the Outlook app and adding your Microsoft 365 email account on your Android device. ————— Step 1: Download the Outlook App 1. Open the ...