Replace WordPress Cron With Linux Cron

WordPress has a built int cron feature that will allow the overall platform and for plugins to run tasks. By default, this cron will be triggered based on user visits. If a user visits the site, the cron will be checked and if a task is due to be executed, it will run and perform whatever task it has been instructed to run. This is generally quite good but the cost of this check still falls on the user that visits the website.

Why would you disable WordPress cron?

If you have a low volume website, the cron tasks may not run due to a lack of visits to the website. You may want to keep plugins up to date and make sure other critical things are kept up to date. This won’t work well if people are not visiting the site to trigger the cron jobs.

On the other end of the scale, if you have a very high volume website, you will have many visitors per second. It is a waste of computing power to have every single visitor be responsible for checking whether cron tasks need to run.

On the other side, we all use cache plugin these days. Bigger sites might even use a reverse proxy. These cache hits will never hit the WordPress code and as a result, will not have the chance to check if cron needs to run. You could get 10’000 hits in an hour and if all of them are cache hits, WordPress’s PHP code will never execute and as a result, cron will not run.

The solution to both of these problems is the same. Disable the default WordPress cron behaviour and make use of the baked-in cron system that comes with all Linux servers.

How To Disable WordPress Cron

Disabling cron is pretty simple. Go to the wp-config.php file in the root of your WordPress install and add the following line of code. This will turn off the default cron functionality.

define('DISABLE_WP_CRON', true);

At this point, no more cron tasks will be executed until you update your Linux crontab to perform the call. The line of code below should be added to your cron files. This is normally found in /etc/crontab but may vary depending on what flavour of Linux you are using.

This entry will make a call to the WordPress cron system every 15 minutes, which is what the default is for WordPress already. You can increase or decrease this as often as you like.
*/15 * * * * root php /var/www/nerdpress/wp-cron.php >/dev/null 2>&1

Advantages of Using Linux Cron For WordPress

The main benefit of using Linux cron for WordPress is a big increase in efficiency. Linux cron is a battle-hardened system that is incredibly efficient. Your operating system will already be using and running this so the extra cost of adding an additional line is very small. The processing will only be performed when needed.

From the PHP side, when a user visits your website, no processing time will be spent checking whether the WordPress cron needs to run. Linux will run it every 15 minutes and no wasted processing will be performed. For very high and very low volume websites, this is one of the best things you can do to squeeze a little more juice out of your web server.

Related Articles

Related Questions

WordPress Table of Contents Plus Not Working

I have been using this plugin for a while and i really like it. It seems to have completely stopped working recently. I can...

Function Keys Reversing Between Fn Actions And Normal

My keyboard has the usual F1 to F12 keys along the top. I use these for shortcuts in various applications. These keys also have...

Whirlpool Oven F6E6: Appliance Manager 1 Board Communication

I have a brand new Whirlpool oven W11I OM1 4MS2 H or (859991549450). I bought it alongside the microwave combi oven. I have had...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Latest Tools

List Sorting Tool

Welcome to our innovative list ordering and management tool. This next-level platform enables you to sort a list of items in ascending or descending...

Sudoku Solver

Welcome to our free online Sudoku solving tool, an interactive platform for puzzle enthusiasts seeking a break from a Sudoku conundrum. This advanced platform...

Apply Image Filters To Image

Digital imagery in the modern world is all about reinforcing emotions and stories behind each photo we take. To amplify this storytelling, we are...

Add Watermark To Image

As the world is increasingly consumed by digital media, protecting your original images is paramount. We are thrilled to introduce you to our innovative...

CSV To Xml Converter

Welcome to our CSV to XML converter tool, a convenient and user-friendly solution for all your data conversion needs. This versatile tool on our...

RGB Image Splitter

Welcome to our innovative RGB Splitter - a unique image analyzer tool that offers an in-depth peek into the building blocks of your photos....

Latest Posts

Latest Questions