On Every Visit WP-Cron Gets executed, Which Might Start Multiple Processes And Add Errors in PHP5-FPM Log With Label wp-cron.php?doing_wp_cron. Previously, we have discussed about the proper settings for setting up UNIX socket for Nginx and PHP5-FPM – we basically mentioned there about disabling this wp-cron.php
function. This article named all about wp-cron.php?doing_wp_cron will discuss a bit more than the fix of the issue.
What The Hell is This wp-cron.php?doing_wp_cron?
wp-cron.php
is a PHP based Cron.wp-cron.php
is a small PHP file which tries to simulate the normal cron-jobs. But unlike cron-job, it is not executed every ABC amount of Time in Minutes like Cron-Job. wp-cron.php
, for example gets executed when a visitor visit the website. wp-cron.php
possibly was build to run it as a separate process in the background to avoid waiting by the visitor. But, wp-cron.php
gets executed on every visit, this cause multiple processes to start and for optimized backend, can fail the PHP or PHP5-FPM.
From our calculation, website which gets around 100 visits per minute, starts around 50 separate wp-crons. Ultimately the PHP processes running in the background fails.
---
The action of wp-cron.php?doing_wp_cron
can be evoked more badly by any SEO Plugin or Cache Plugin or natural checking for plugin updates or clearing the cache and more such functions. wp-cron.php
does not run all the time in the background the way the name might suggest and real Cron does. That type of scheduling is not possible for a PHP-MySQL based web application like WordPress, so when load increases practically wp-cron.php
puts more pressure.
How To Fix This wp-cron.php?doing_wp_cron Error?
If you follow our guide for settings for setting up UNIX socket for Nginx and PHP5-FPM, you’ll learn how to set cron from SSH. On webhosts with a control panel, there will be ways to set cron. Frankly, you need to disable the wp-cron.php?doing_wp_cron
function by adding this line in wp-config.php
file :
1 | define('DISABLE_WP_CRON', true); |
If you have rightly set the cron via SSH, your normal functions of WordPress like Plugin Update Notification, Caching by WordPress Plugin will not get hampered. You should talk with your web host in cPanel or any control panel based hosting for properly setting the cron.
We do not think, there is any reason to use any PHP based fix of thewp-cron.php
file. Disabling the function, actually increases the server response time, decreases the probability of facing HTTP errors by both human and bots.