By default, automatic task handling in WordPress is controlled by wp-cron.php. This script is used by WordPress to run scheduled tasks for your WordPress site. Unfortunately, this file is set to be called on every page view, even when it isn't needed, which in turn can cause higher than needed use of resources on the server.

WordPress defaults to this behavior because some hosts do not allow manual cron jobs to be created and the tasks have to be carried out by this script instead. Since WordPress can be installed on so many different hosts, the developers are trying to make sure it will run as expected whatever the environment.

Once a blog begins to add users and traffic increases, this can cause issues for your account because the script is called for every single page view. Fortunately, it's fairly easy to disable this default behavior and set up a proper cron job through cPanel for WordPress task management. This will be a much more efficient way to run the tasks needed for WordPress, and can even optimize your WordPress site.

Disabling wp-cron.php in WordPress

  1. Begin by logging into your cPanel account.
  2. Enter the File Manager area of cPanel by clicking on the File Manager icon under the Files area of your cPanel home page.filemanager1
  3. The wp-config.php which we need to add a line to is located in the directory where you have installed WordPress. In our example, we have installed WordPress to wp.whhsupport.com so our path will be public_html/wp (the document root for that subdomain).wp-cron-wp-config
  4. If you receive a pop up notification regarding encoding, make sure utf-8 is selected in the drop down menu.
  5. Add the following code to your wp-config.php file, this can be placed right at the top of the file before your database settings.

    define('DISABLE_WP_CRON', true);

    wp-cron-disable-code
  6. Click the Save Changes button and then the Close button.
  7. You can now exit the File Manager (by closing the tab or window it is in) and return to the cPanel home page.
We've now disabled wp-cron.php from automatically running each time someone visits a page of our site. But we still want the cron to run so that tasks can be managed, we just want to have a little more control over how often the wp-cron.php script runs.

Setting up a Cron Job to Run wp-cron.php

  1. Back in the cPanel home page, click on the Cron jobs icon under the Advanced area.
    cron1
  2. In the Cron Jobs page, we will set how often the cron will run and the command to run our WordPress cron script.
  3. For time period, we recommend that you do not run this cron more often than every 5 minutes. In fact, if you do not make frequent updates to your WordPress site, you could even set this to a longer time frame (e.g. every 1 or 2 hours)
  4. The command you will want to input will be similar to:

    php -q /home/userna5/public_html/wp-cron.php

    Make sure that you replace userna5 with your actual cPanel user name and that the path to wp-cron.php includes the full path to that file. For this example since I have WordPress installed on wp.whhsupport.com (with the document root of that subdomain being public_html/wp), my command would look like:

    php -q /home/whhsup5/public_html/wp/wp-cron.php

    wp-cron-new-cron
  5. Click the Add New Cron Job button to save your new cron job.

We've now disabled the default WordPress cron behavior and created a more reasonable cron job for WordPress task management.

Keep in mind with these changes that when you make changes to your WordPress site, it may take a few minutes for the changes to appear as the cron will need to run the tasks needed. If you have any questions, please feel free to submit a question in our Support Center.

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Did you find this article helpful?

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!

Help Center Search

Current Customers

Email: support@WebHostingHub.com Ticket: Submit a Support Ticket
Call: 877-595-4HUB (4482)
757-416-6627 (Intl.)
Chat: Click To Chat Now

Ask the Community

Get help with your questions from our community of like-minded hosting users and Web Hosting Hub Staff.

Not a Customer?

Get web hosting from a company that is here to help.