Disabling the WP-CRON.php in Wordpress

Wordpress uses a file called wp-cron.php as a virtual cron job,
a task that is scheduled in order to automate things such as publishing posts,
checking for updates to the theme or a set of plugins,
notifyings users via email and much much more.

By Default Wordpress is configured to summon wp-cron.php every single time a person visits your wordpress powered website when a scheduled task exists,
to basically ask "do I do anything yet? What time? How about now?"

On sites that have very low traffic this is quite normal but as your traffic begins to spike and settle at a higher rate,
checking multiple times for tasks that are scheduled can be extremely inefficient and cause excess resourse usage on your server,
on top of that your entire website would be much slower to access.

Disable default WP-CRON.php behavior

We can simply tell wordpress to let us handle the execution of wp-cron.php with the wp.config file.

First step: Open your wp-config.php file with the cPanel code editor.

Second step: Go to the bottom of the database settings, most commonly around line 37

Add the following code: define('DISABLE_WP_CRON', 'true');

Final step: Save it


Now that we have finished that, wordpress will not autorun the wp-cron.php script each time your site gets a new user/visitor

Setup manual cron job for WP-CRON.php

We really don't wnat to leave wordpress running without any ability to automate tasks that it might need to do.

But at the very least now that its not running for every single visitor,

we can have alot more control over the tasks that take place.

For alot of the wordpress users having wp-cron.php script run every 5-6 hours if perfectly fine.

That would be a total of 4 executions daily,

compared to hundreds and thousands if you had alot of traffic on that particular day.

 

Step 1: Login into cPanel

 

Step 2: Underneath the advanced section, select Cron jobs.

 

Step 3: Select once an hour from the common settings drop down.

 

Step 4: Now select every 5 or 6 hours from the hour drop down menu.

 

Step 5: Finally fill the code to run our cron job and click add new cron job.

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

 

Step 6: You should see a success messege that your new cron job has been added successfully

  • 79 Users Found This Useful
Was this answer helpful?

Related Articles

How to hide wp-admin login page?

Mostly WordPress websites are hacked or brute forced through wp-admin login page. Here is a way...

How to install SSL certificate on your WordPress website?

There are three simple steps to setup your SSL certificate on your WordPress website   1. Get...

How to create a staging environment in WordPress

Login into DirectAdmin and click on Wordpress under the app installer.    Go to "All...

How to install WordPress using Softaculous

Step 1:    Log into your DirectAdmin panel when you select your service as shown below....