How to Disable the wp-cron.php in WordPress?

Wordpress uses wp-cron.php to schedule the task for the wordpress websites, such as scheduling a post to publish, checking for the new wordpress version, plugin, theme updates, email sending notification, etc. However, there is a limitation. By default, wp-cron requires a back-end or front-end visit to function. Otherwise, wp-cron can't run the scheduled task. Wordpress website with high traffic doesn't occur any issue, but a website with low traffic can cause missing schedule tasks.

Another issue that can occur with wp-cron is performance. WP-cron works by checking with every page load. When a wordpress page loads, it will check for the list of scheduled tasks to see what needs to run. Website pages will check for the scheduled task each time it is visited. On a high-traffic website, this can lead to high resource usage and make your website speed slower.

How to disable default wp-cron.php behavior?

Please refer to the following steps to disable Wp-cron to run on cPanel. 

  1. Log in to your cPanel account. 

  2. Go to your Wordpress website path. 

  3. Open your Wp-config.php file. 

  4. Inside wp-config.php, add the below line after the database settings.

    define('DISABLE_WP_CRON', true);
  5. Finally, click on the Save Changes button.

Now, Wordpress will not run the wp-cron.php script each time the website has a new visitor after making these changes.

How to set up a manual cron job for wp-cron.php?

We shouldn't stop all the automatic tasks on the Wordpress website entirely as some of the tasks could be very important. However, it shouldn't run with every single visitor. We can set up control on how these tasks can run. We can set the wp-cron.php to run every 12 hours. It will run two times in 24 hours. It is better in comparison to the default behavior of wp-cron.php. You can set up this time as per your website requirement.

  1. Log in to your cPanel.

  2. In the advanced section, click on the Cron Jobs.

  3. At the common settings drop-down, select Twice Per Day. Once you choose, it will automatically fill the hour section with Every Twelve Hours (0,12).

  4. Inside the command section, add the below command. Replace the cPanel_user with your cPanel username. Here, we have used the path of the primary domain. If you want to do this for the addon or sub-domain within the cPanel, you can change the path accordingly.

    cd /home/cPanel_username/public_html; php -q wp-cron.php 
  5. Finally, click on Add New Cron job button. 

After setting up the manual cron job for wp-cron.php, your Wordpress website should run the scheduled task at the set intervals. 

Related Articles

How to write a comment in WordPress

Video Tutorial Get Wordpress Hosting

How to add Google reCaptcha Protection on Wordpress?

Google reCAPTCHA is a free service from Google which helps to protect your websites from spam and...

How to Enable Gzip Compression for WordPress via .htaccess file?

When Gzip compression isn't enabled on WordPress website, Google PageSpeed Insight gives you a...

How to Install WordPress Through Softaculous?

Once you get the Login details for your cPanel account, You can easily install the WordPress with...

  • 0 Users Found This Useful

Was this answer helpful?