There was a problem loading the comments.

How to Disable the wp-cron.php in WordPress

Support Portal  »  Knowledgebase  »  Viewing Article

  Print
WordPress uses a file called wp-cron.php to automate things like publishing scheduled posts, checking for plugin or theme updates, sending email notifications and much more.

Did you know that by default WordPress will load wp-cron.php every single time somebody visits your WordPress website to check if a scheduled task is present.

On low traffic sites this is perfectly fine, but when visitors roll in, checking multiple times for scheduled tasks can be very inefficient and quickly leads to resource usage problems for your WordPress website which can make your website load slower or worse cause errors. The answer to fixing this default behaviour is simple, disable wp-cron.php and create a real cron job.

Disable wp-cron

To disable the WordPress default wp-cron behaviour add the following line to your wp-config.php file:

define('DISABLE_WP_CRON', true);

Setup a real cronjob

For most WordPress users having the wp-cron.php script run every 3 hours is perfectly fine. That would be just 8 executions in a day, compared to possibly hundreds, or even thousands if you had a lot of visitors that day.

Step 1 - Log into your cPanel.

Step 2 - Under the Advanced section, click Cron Jobs.
e9d961bc4a57257ad3f9506e776d6828de7be4e3?t=409c2c41272b9c6caafd1bc45a9a174f

Step 3 - Scroll to the Common Settings drop-down and choose Once Per Hour(0 * * * *).
1605b94ae31d686e40be747f12354fd0a8af85a4?t=b9a00e00bff27fa7a9ec59f43b9c2f26

Step 4 - Now select Every Third Hour(*/3) from the Hour drop-down.
e634c79c933687ec3db6a9e808dedf10d533fea6?t=cd6023bbdc3979ea05b767b047887dc8

Step 5 - Finally fill in the code to run our cron job and click Add New Cron Job.
7f19e5f397d1a92a455ba7ec22eb7025a536a756?t=1d11de287c1774d9032f6305c041c403

Please note that the exact command will depend on your cPanel username, simply replace the word username in the example below with your own cPanel username.

php -q /home/username/public_html/wp-cron.php
Where username is your cPanel user name.

Keep in mind that the /home/username/public_html path would be for a primary domain, if you're using an addon domain, or have WordPress installed in a sub-directory you'll want to be sure to update your path.

Step 6 - Confirm that your new cron job appears in the list of Current Cron Jobs.

7a0cdd251f683f5fd324585bc9c69021324960a5?t=eca71946efaa78e47ef3ddbf8db05216

Your wp-cron file is now setup to run by an independent PHP process so it will not interfere with any visitors page-requests.

Because of this, we highly recommend running wp-cron this way rather than WordPress’s default way, irrespective of size or traffic of your site.

Share via
Did you find this article useful?  

Related Articles

© HOST100