How to Disable wp-cron in WordPress and Set Up Proper Cron Jobs

Affiliate disclosure: In full transparency – some of the links on our website are affiliate links, if you use them to make a purchase we will earn a commission at no additional cost for you (none whatsoever!).

Do you find that WordPress’s scheduled actions do not function as expected sometimes?

WordPress is equipped with a scheduling mechanism known as wp-cron; however, there are times when this system fails to complete a scheduled activity, such as publishing scheduled articles or sending triggered emails. Cron tasks that are properly configured and run by the operating system of your server are typically more reliable.

This post will walk you through How to Disable wp cron in WordPress and Set Up Proper Cron Jobs

How to Disable wp-cron in WordPress and Set Up Proper Cron Jobs

Why Disable wp-cron?

Your WordPress website already has an integrated scheduling system that is referred to as wp-cron. It carries out time-sensitive duties like as checking for updates, publishing scheduled posts, automatically producing regular backups, sending triggered emails, and many other similar activities. You can get additional information by reading our article on how to see and manage cron jobs in WordPress.

How to Disable wp cron in WordPress and Set Up Proper Cron Jobs

The issue is that WordPress is only asked to check for scheduled jobs when someone visits your website. This can be problematic. This works adequately for the vast majority of sites, but on occasion it may present challenges for more modest ones.

For instance, if your website does not receive a lot of visitors, the posts that you have planned could not be published at the appointed time. In addition, if your website receives a high volume of visitors, wp-cron will be checked more frequently, which could negatively affect the performance of your website.

Now, if all you want to do is cure the error about missing scheduled posts, you can use the free plugin Missed Planned Publisher; but, if you want to tackle all of the problems associated with scheduled actions, you will need a genuine cron job.

Instead of running the cron job, WordPress relies on the operating system of the web hosting server to do so. It is possible to configure it to do more reliable checks on scheduled tasks. You won’t have access to configure this on the server by default when you use WordPress; however, if you follow the steps in our article, you’ll have no trouble doing so.

With that out of the way, let’s investigate the process of disabling wp-cron and establishing a cron job the right way.

Disabling wp-cron in WordPress

To disable wp-cron, you need to edit wp-config.php, which is a core WordPress configuration file. You will need to use an FTP program or the file manager that is included in your web hosting control panel to access it, as it is situated in the root folder of your WordPress website.

Because of the sensitive nature of the data included in this file, modifying it in the wrong way can cause your WordPress website to become inaccessible. In the event that something went wrong, we strongly suggested beginning by creating a backup copy of the file. You can learn how by following our guide on how to edit wp-config.php in WordPress.

You’ll need to paste the following code into the wp-config.php file just before the line that says ‘That’s all, stop editing! Happy blogging.’

define('DISABLE_WP_CRON', true);
Pasting Code into wp-config

Following that, you will need to save the file and then upload it to your website again.

When someone visits your website, WordPress will no longer trigger the cron job using wp-cron.

Setting Up a Proper Cron Job on Your WordPress Host

In order for your scheduled tasks to be executed, you will now need to properly configure a cron job. The manner in which you accomplish this task will change based on the tools that are made available to you by the WordPress hosting service you use.

Using cPanel, a popular website management panel that is included with many web hosting plans including Bluehost’s, is the easiest way to set up cron tasks. Bluehost is one of those web hosting companies. In this lesson, we will be utilizing the cPanel provided by Bluehost.

Note that not all web providers use cPanel, and some of them might not even let you create cron jobs on their servers. In the event that you have any questions, you should get in touch with your hosting provider or read through their help material. You always have the option to use a cron service provided by a third party (below).

After you have logged into your hosting account and found your way to the cPanel, you will need to scroll down until you see “Cron Jobs,” and then you will need to click on it.

You might be able to find it under the ‘Advanced’ area, however the location of this part can change depending on the hosting service you choose.

Find 'Cron Jobs' in cPanel

This will send you to a new page where you may create new cron jobs.

Don’t worry about the warning you’ll notice about needing a solid grasp of Linux commands. Only one command is necessary, and we’ll show you exactly what it is below.

How to Import External Images in WordPress

The cPanel Cron Jobs Page

If necessary, you have the ability to update the email address that will be used to send notifications regarding cron jobs. The address that you used to sign up for your website hosting is the default address, and this address will function well on the vast majority of websites.

Now that we have reached the bottom of the page, let’s set up a cron job by scrolling down to the area labeled “Add New Cron Job.”

To begin, you will need to determine how frequently the cron job will be executed. You are free to do whatever you want here, but the recommended time frame is 30 minutes.

You will need to click the “Common Settings” option, then choose a time interval from the dropdown menu that appears after clicking the “Common Settings” button. If you are unsure which option to go with, “Twice Per Hour” is a suitable choice for most websites.

Creating a New Cron Job in cPanel

Now is the time to type the command that will ask WordPress to carry out the actions that have been scheduled. In the space designated for ‘Command,’ you must copy and paste the following code:

wget -q -O - https://example.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1

Make sure that the ‘example.com’ in the following URL is replaced with the URL of your own website.

After you have finished doing that, ensure that you click the button labeled “Add New Cron Job,” and you will notice that the new cron job has been added to the list below.

Viewing the List of Cron Jobs in cPanel

Instead of only checking for and doing scheduled tasks when someone visits your website, WordPress will now check for and perform them every 30 minutes.

Setting Up a Proper Cron Job Using a Third Party Service

You can make use of a cron service provided by a third party in the event that your web hosting package does not provide appropriate cron jobs or if it is difficult to set them up.

These are specialized services that give you the ability to configure cron jobs through an intuitive user interface. The following are some of the more impressive ones:

There is a free plan available on EasyCron, but it must be renewed every month.

cron-job.org is a website that offers a free service.

If you only require one cron job, Cronitor is completely free to use.

SetCronJob provides paid plans, with prices beginning at $10 per year.

In this lesson, we will be use EasyCron because it is simple to use and the free plan is adequate for the majority of the use cases seen by beginners.

After setting up a free account, you will see a button labeled “Add Cron Job” on the left side of the screen. Clicking this button will allow you to create a new cron job.

Creating a New Cron Job in EasyCron

The ‘Create Cron Job’ screen will appear as a result of clicking this button. To begin, you will need to copy and paste the following URL into the space designated for “URL to call.”

https://example.com/wp-cron.php?doing_wp_cron

It is imperative that you change “example.com” to the URL of your own website.

Creating a New Cron Job in EasyCron

After that, use the drop-down menu labeled “When to execute” to select “Every 30 minutes” as the time interval. After you have completed, it is imperative that you remember to click the “Create Cron Job” button in order to save your configurations.

Your website’s wp-cron will be executed every half an hour by the new cron job, which will then be added to the list.

Aishwar Babber

Aishwar Babber is a passionate blogger and a digital marketer. He loves to talk and blog about latest tech and gadgets, which motivates him to run GizmoBase. He is currently practicing his digital marketing, SEO, and SMO expertise as a full time marketer on various projects. He is an active investor in NewSmartWave and ImageStation.

Leave a Comment