PDA

View Full Version : wp-cron.php causing high load on server, long running script



Fli
09-27-2015, 01:43 PM
WP-CRON.php is making sure emails are sent out, scheduled posts are published, updates are checked etc.

This script can take a long time on big sites so this is my treatment:

I added following line into wp-config.php (below "<?php")

define('WP_CRON_LOCK_TIMEOUT', 900);
in aim to do not allow wp-cron to run more frequently than each 900 seconds

I setup cronjob to kill wp-cron.php process every midnight so there is no indefinatelly running wp-crons


52 23 * * * root pkill -f "wp-cron.php"

this line i added into file /etc/cron.d/myjobs which have 0600 permissions and root:root

---
It is also possible to disable wp-cron from within wp-config.php by adding:

define('DISABLE_WP_CRON', true);
and then setting up cronjob to run wp-cron manually:

wget -q -O – http://yourdomain.tld/wp-cron.php?doing_wp_cron >/dev/null 2>&1

kumkum
10-20-2021, 03:10 PM
If wp-cron consuming too much resources then we can disable it in Wordpress.
For that you have to add below line in wp-config.php file:
Define(‘ DISABLE_WP_CRON’ , true);
And now save the file.

If you want to run any cron then you can manually create it in cpanel;
Login to cpanel >> Cron jobs

if you want to know more about disable wp-cron.php file (https://hoststud.com/resources/steps-to-disable-the-wp-cron-php-in-wordpress.575/) then you can check.