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

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...

Whats the difference between the Tapo P100 and the P105?

There are a few different Tapo smart plugs. The P100 and P110 differ based on the smart power monitoring feature but where does the...


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

AI Content Detector

We've got this awesome free tool that'll help you figure out if that content you're looking at was written by a human or some...

Image Saturation

Are you looking for an easy-to-use, free app to modify your image saturation levels and make your pictures truly pop? Look no further! Our...

Pixelate Image Tool

Introducing the ultimate free online image pixelator tool that allows you to easily transform your images into stunning pixel art in just a few...

Image RGB Level Adjustment Tool

Introducing the ultimate image color adjustment tool for all your photo editing needs. Our free online tool lets you take full control of your...

Image Color Inverter

Looking for a quick and efficient way to convert your images into negatives? Our Free Image to Negative Converter is the answer! Our online...

Negative Image to Color Image Converter

Welcome to our Negative Image to Color Image Converter, a free and easy-to-use tool that helps you convert your old negative images into vibrant,...

Latest Posts

Latest Questions