How to disable wp-cron.php in WordPress?

wp-cron.php is a file used by WordPress as a virtual cron job. Crons are used to run scheduled task in order to automate things like publishing scheduled posts, checking for plugin or theme updates, sending email notifications and more.

WordPress is setup by default to call wp-cron.php everytime someone visits your WordPress website. This means with every website visit, wp-cron.php is checking to see if there is a scheduled task present, to basically ask itself to see if there anything it needs to do.

On low traffic websites this is perfectly fine, but when your site visits start to increase, checking multiple times for scheduled tasks can be very inefficient and lead to resource usage problems for the server, this will eventually make your website load slower.

For advanced usage, WordPress has made a way to disable wp-cron.php from running with every website visit. Advanced users should take advantage of that and disable default WordPress settings for wp-cron.php and enable a more advanced option. For most WordPress users having the wp-cron.php script run every 12 hours is perfectly fine. That would be just 2 executions in a day, compared to possibly hundreds, or even thousands if you had a lot of website traffic that day.

Disable default wp-cron.php behavior

  1. Open your wp-config.php file with the cPanel File Manager Code Editor
  2. Go to the bottom of the database settings in wp-config.php typically around line 37. Add the code: define('DISABLE_WP_CRON', 'true');
  3. Click Save

Setup manual system cron job for WordPress wp-cron.php

  1. Log into cPanel
  2. Click on cron jobs Under the Advanced section, click on Cron Jobs.
  3. Select Once an hour from the Common Settings drop-down.
  4. Now select Every 12 hours from the Hour drop-down.
  5. Finally fill in the code to run the cron job and click Add New Cron Job - code: "php -q /home/username/public_html/wp-cron.php"

Note: Path "/home/username/public_html" should be replaced by the location of your WordPress installation.

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 to the correct one.

You should see that your new cron job was added successfully.

Now WordPress should be safely running scheduled tasks via the wp-cron.php script, but only at set intervals.

  • WordPress
  • 45 Users Found This Useful
Was this answer helpful?

Related Articles

WordPress 403 Error

WordPress 403 Error can give you issues when opening your WordPress website. In addition to that,...