This KB article will provide you with an overview of what Cron Jobs are and why they are used. Furthermore, you will also learn what is WP-Cron, its disadvantages, and how to disable it.

What are Cron Jobs

Cron is a standard Unix-like/Linux utility, and it is one of the most useful features which schedules a script or command to be executed automatically at a specified date and time. The scheduled commands, scripts, and tasks are called Cron Jobs. This feature was introduced to automate the process of repetitive tasks.

It is highly recommended to be acquainted with the Cron Jobs and their workings to use this feature effectively. Knowing Linux and its commands will be a bonus.

The typical format of the Cron Job command is as follows:

Minute(0-59) Hour(0-24) Day_of_month(1-31) Month(1-12) Day_of_week(0-6) Command_to_execute

Common Applications

Common applications of Cron are as follows:

  • Deleting temporary files that are no longer needed, e.g., log files.

  • Making scheduled backups.

  • Monitoring disk space or other resources.

  • Modifying database or files.

  • Running system maintenance tasks.

What is WP-Cron

WP-Cron is a Cron Jobs management tool of WordPress which handles the time-based tasks of WordPress application such as publishing the scheduled posts, checking for plugin or themes updates, etc.

Cons of WP-Cron

WP-Cron is dependent on users visiting your site, which means that WP-Cron will only execute if the user visits your website. If no one is on your website, it will not run. Due to this, any scheduled tasks will not run until any visitor visits your website. For instance, if you have scheduled any post to be published on a specific day and time and no user visits your site at that time, then it will be delayed. Also, your WordPress dashboard will say ‘delayed’.

As discussed, WP-Cron depends on users, so if there are fifty visitors on your site at the same instant, it will cause WP-Cron to be executed fifty times. If twenty of your visitors click on the same link, then WP-Cron will be executed twenty times again, which will increase the load time of your page, and the site’s performance will be affected. Search engine bots are treated as real visitors when they crawl over your website when related queries are triggered on the search engine.

Tip:

It is recommended to use the Cloudways system cron handler instead of a built-in cron handler for blistering performance.

How to Disable WP-Cron

Disabling the WP-Cron is very easy by following the steps below.

Step# 1

First of all, you need to connect to your server remotely via SSH so you can use WP-CLI.

If you would like to know what is SSH and why it is used, then Click Here to find out. In this example, we are using Master Credentials to access the server remotely.

You can connect to your server via SSH in two ways, so choose your preferred option from the below options. You can also click on the hyperlink text of bullet points to learn about connecting remotely to the server.

In this example, we have used an SSH client named PuTTY. You will see a similar window after successful connection as shown below:

Step# 2

Now, you need to locate the wp-config.php file which is by default located in the public_html directory of your web application.

Type this command and hit Enter to go to the target directory.

cd applications/<your_application_name>/public_html/

Important

Angle brackets are included to indicate the positions of your inputs, so make sure to remove the angle brackets. Your application name is the same as your Database name (DB name). Click Here to find out where your application name is located.

You will see a similar window after running the above command successfully.

Then, type listing command to view files and folders and to locate wp-config.php file.

ls

Part B: Editing wp-config.php File

Now, you need to edit wp-config.php file by executing this command:

vim wp-config.php

Next, scroll all the way to the bottom and press i to edit the file and add this rule before the line where it says /* That’s all, stop editing! Happy blogging. */

define('DISABLE_WP_CRON', true);

Press ESC after writing the rule. Then, type this command mentioned below and hit Enter to save the file.

:wq!

Step# 3

Now, if you would like to verify that WP-Cron was successfully disabled, then you may type this command and hit Enter .

wp cron test

You will see a confirmation message, as shown in the above screenshot if the WP-Cron is successfully disabled. You can also list WP-Cron events as well using the WordPress CLI, which helps you to view all the scheduled WP-Cron events.

You have learned about disabling the WP-Cron for better performance. Here comes the next step of setting up the Cron jobs from the Cloudways Platform.

That’s it! We hope this article was helpful. If you need any help, then feel free to search your query on Cloudways Support Center or contact us via chat (Need a Hand > Send us a Message). Alternatively, you can also create a support ticket.

Did this answer your question?