PHPMatters Help You Better Hosting Your PHP-based Sites
How to Fix up wp-cron.php Issues in Shared Hosting

How to Fix up wp-cron.php Issues in Shared Hosting

Have you ever doubted whether wp-cron.php gives rise to traffic jam on your WordPress website now and then? If so, you may wish to dig out the truth and make certain whether you should turn to an alternative instead of wp-cron.php. In this post, we are going to describe wp-cron.php in details and tell the reasons why it should be disabled.

And then, an in-depth guide comes to show you how to fix up wp-cron.php issues in shared hosting by setting up real cron jobs.

What Is wp-cron.php?

The wp-cron.php is a file included in WordPress by default, which acts as the normal cron jobs to schedule tasks on the server, such as checking themes & plugins updates, publishing scheduled posts, sending pingbacks, and so on. In this way, all scripts or commands are run automatically at the scheduled times. However, there is a big difference between wp-cron.php and a cron job, and it is also the main reason that makes wp-cron.php sucks.

Why Disable wp-cron.php?

why disable wp-cron.phpIn general, many WordPress hosting providers set the cron job intervals as 15 minutes. We suggest you to extend the time interval complying with this standard or even longer than 15 minutes. This is because that the longer the time interval is, the more burdens are eased on a server. That is to say, more requests to the server once a time will take more usage of CPU and the server memory. In this way, the web host can guarantee a high level of performance.

Nevertheless, wp-cron.php is not that kind. This file gets down to work once there is a visit on your website. If your website sustains a large amount of daily visits, you should take action to turn to a real cron job instead of the default wp-cron-.php. This is because that a swarm of visits cause the same number of actions for wp-cron.php. And then, a great deal of CUP usage and server memory is taken to deal with those requests. That is the main cause to bad performance. If you are running a website with low traffic, then there is no need to make any change.

Another common issue caused by wp-cron.php is that the scheduled posts fail to get published. This is because that the wp-cron.php file has not received a page request somewhile. Maybe now, you have been ready to go to a real cron job and wish to disable the default wp-cron.php right now. Here, we have made an in-depth guide as below and hope that it will become a part of your success.

How to Disable Default wp-cron.php?

For the wp-cron.php being generated by default, you are required to disable this file at first. Honestly, it is not difficult to get it down because you just need to add some codes to wp-cron.php file. Open this file in an editor that can be whatever you want and then copy and paste the highlighted codes in the text.

disable default wp-cron.php

How to Set up Cron Jobs?

And now, wp-cron.php stops scheduling jobs on the server automatically. Here, we are going to set up real cron jobs via a control panel. For most shared hosting providers integrating with cPanel, like BlueHost, we make the following demonstration on this powerful control panel. First of all, you are required to log into cPanel and go to Advanced > Cron Jobs.

set up cron jobs

And now, you are in the face of a bunch of settings under “Add a New Cron Job”, which enable you to set the intervals in specified times. The Common Settings allow you to determine how frequently the cron job should be acted. Besides, the next fields leave enough room for you to determine the time in a certain minute, hour, day, month or weekday.

In most cases, it is great to enable cron job to work every 15 minutes or even a longer time interval. Thus, you need to select Once Per Minute (*****) in Command Settings filed and select Once Per Fifteen Minutes (*/15) in Minute field as what we show you in the following screenshot.

set up cron jobs

Certainly, you are allowed to make more changes as your want. For instance, if you wish to regard the interval as 6 hours per day, you are required to select Once Per Hour (0****) in Common Settings and select Every Six Hour (*/6) in Hour field.

Keep in mind that the five symbols included in the parenthesis, like (*****), substitute minute, hour, day of month, month and day of a week respectively.

And then, you are required to enter the following command in the Command field. Note that, you have to replace with your site domain.

wget -q -O -

set up cron jobs

Besides, if you wish to fix an exact time to enable the cron job, such as 6am on Thursday, December 25th, 2014, then you need to follow the settings as below.

set up cron jobs

Click Add New Cron Job button to finish this process. The following words remind you that the new cron job has been created successfully.

set up cron jobs

By now, all cron jobs are shown under the Current Cron Jobs, which enables you to edit or delete an existing cron job.

set up cron jobs

If you wish to know the status of each cron job in time, then you need to enter an email address in the Email field and click Update Email button. In this way, you will receive an email when a cron job runs a command.

set up cron jobs

Setting up cron jobs via cPanel is an effective to achieve the goal, and it is easy to handle and understand, even for beginners. Thus, we suggest you to go with a reliable cPanel hosting providers thereby listing some recommendations in the following table.