How cPGuard can fix the wp-cron.php nightmare

What is wp-cron.php 

WordPress comes with  a default job scheduler which is actually a  virtual cron job using file called wp-cron.php. This is used to schedule task in order to automate things like publishing scheduled posts, checking for plugin or theme updates, sending email notifications and more.
So everytime the website get a hit and you have any scheduled task is present in that website, the task is to basically ask "is it time to do anything yet?". This can be anything like

Publishing of the scheduled posts
Plugins or Theme updates check
Sending notifications
Taking backups
WordPress automatic updates
etc

How it can be  a problem for your server

Of course you need to run the wp-cron.php scheduler to do some important jobs on your website like updates check and backup. But if you leave the default virtual cron job enabled, this check will happen with every hit. On a server with some low traffic websites, this is perfectly fine. But when your site visits start to increase or you have so many Wordpress websites with moderate hit such a  scheduled tasks check for each website can be very inefficient and lead to resource usage problems for the server, this will in turn make your website load slower. We have had a situation where the CPU load on the server has doubled only due to wp-cron.php execution on all websites. 

How cPGuard manage this issue?

We have certain jobs which is collecting all informtion about the Wordpress websites on your server and it keeps updating the information. So we use this information and run some logic to disable the cron job in each Wordpress website, add a cron job under the user for each Wordpress installation and configure each job to run multiple times intermittently a day and the run time for the users are synchronously distributed. We carefully calculate the run time for each Wordpress wp-cron ( by assigning random hours and minutes ) and thus avoid the load due to running them all together. It is perfectly fine to run the job few times  a day for moderate traffic website and if any of the user wants to change the scheduled time, they can update it from their control panel. This approach will help to reduce the server load due to wp-cron.php in a large scale and efficiently run them without any overhead to your website and server.

Is it useful for everyone?

Not really, this is helpful for people only running too many Wordpress websites and suffering from the wp-cron.php load. Do not enable this feature without knowing what you are doing. You may not find it useful if you have a low number of Wordpress websites on your server or the websites get rare traffic. But if you have a handful of Wordpress websites with moderate traffic, this will be a cool feature and it can save a lot of your server resources. 

How to enable this feature?

You can enable this simply by going to cPGuard >> Settings >> Additional Settings >> Enable "Override WordPress wp-cron.php" and select the "Interval for running wp-cron.php".

wp-cron image

 

Is it possible to revert this anytime?

Of course you can ...cPGuard provide options to revert the configuration updates. To revert all the changes done by cPGuard to manage wp-cron jobs, , go to cPGuard >> Settings >> Additional Settings >> Disable "Override WordPress wp-cron.php" . Please note that it will take up to a few minutes to complete the changes.

Still need clarification?

Please feel free to contact our support team anytime and we are happy to answer your questions. 
 

Please rate this article to help us improve our Knowledge Base.

0 0