disable wp-cron

How to Disable & Replace WP-Cron for Better Performance

WordPress is designed to work on nearly any hosting environment, not all of which come with a scheduling service. WordPress does have maintenance tasks it needs to perform on a regular basis, but if it can’t depend on the hosting server’s systems, it has to provide its own.

That’s what the wp-cron system is. It works by hooking every single page request WordPress handles, and this gives WordPress a chance to perform maintenance tasks in the background every time a page request is made to the site.

The problem is, it tends to slow down the website because now it’s not just handling time-sensitive queries to the server, but also doing maintenance tasks at the same time. This ends up slowing down page response times, making the site feel slower than you would expect.

There is a solution though! The WordPress developers left in a way to turn off wp-cron, in favor of a system scheduled task. This is done in two steps.

How to Disable WP-Cron (wp-cron.php)

Step 1:  First, disable the wp-cron script. Find and edit the wp-config.php file, and add this line just above the “/* That’s all, stop editing! Happy blogging. */” line:

define('DISABLE_WP_CRON', true);

It should look something like this:

Disable WP CRON

Step 2:  Next, open the ‘Cron Jobs‘ icon in cPanel, and set up a new job. This new job should run every hour, and should execute this command:

/usr/local/bin/php -q /home/username/public_html/wp-cron.php >/dev/null 2>&1

The >/dev/null 2>&1 part of the command above disables email notifications.

cpanel hourly cron job

wp cron command

The ‘username’ in the command should be your cPanel username. If your WordPress installation is not the main domain of your account, you will also need to adjust the path to point to your WordPress document root.

If your hosting service is not using cPanel, you may need to contact your hosting provider to find out what scheduling services are available, and how to configure them.

At HostUpon, all of our WordPress Hosting plans include our WordPress Manager which allows you to disable wp-cron without having to edit any files or code.

Add comment