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

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

Time remaining keeps going up on Whirlpool dryer??

I have clothes in the dryer regularly and the time remaining shows on the display. There could be 10 mins remaining and if I...


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

Memory Converter

Converting values between various metric measurements is usually quite simple as there will be 1000 of the smaller unit in the next larger unit....

Bitrate Converter

Below you will find a bitrate converter. This tool will allow you to enter a bitrate value, in one of many different formats and...

Aesthetic Text Generator

There are various ways to make your social media profile seem more unique, some of which are not as easy to implement as others....

Aspect Ratio Calculator For Images

Aspect ratio is the ratio between the height and width of an image. If you want to resize an image by 100 pixels, you...

Add Text To Image

Use this free tool to add text to an image. Simply select the image file that you want to overlay text onto and you...

JavaScript Multi-line String Builder

Javascript did not always support multi-line strings. If you attempted to create a string variable using quotes, putting a line break into the source...

Latest Posts

Latest Questions