Your WordPress site seems to be have performance issues or you are getting high hits on your website and because of that the “wp-cron” is running too frequently causing performance issues on website. Today i will tell you how to disable wp-cron for faster performance. To start with the process lets first know
What is cron job?
The jobs which are used to schedule tasks to be done at a fixed time, day or date on your website are known as cron. Backing of data, scheduling posts to publish, checking for updates, etc are few tasks that your WordPress site performs. Now here in WordPress all these scheduled tasks and activities are handled by wp-cron(WordPress cron). If you have a high amount of traffic, utilizing the default cron handler can have a negative impact to your website performance. WP-cron does not run continuously. It is triggered with every page load, If the traffic is high it can cause problems.
How to overcome the performance issue?
The best thing we can do here is to disable wp-cron and use the system cron to run the wp-cron. You can schedule the execution depending on your requirement , but the most common and preferred one is which runs twice an hour.
How to disable wp-cron?
Disabling wp-cron is quite simple, you need to add the below piece of code to you wp-config.php(WordPress configuration file). Place the code just above the line saying “/* That’s all, stop editing! Happy blogging. */“.
define(‘DISABLE_WP_CRON’, true);
Lets talk disabling cron in little detail, First of all you need to login to your hosting provider Cpanel or website’s FTP and navigate to file manager. Once you are in your file manager go to WordPress installation directory, In FTP you to navigate to WordPress installation folder. Go to the file “wp-config.php”
Now edit that file and update it with “define(‘DISABLE_WP_CRON’, true);” this piece of code, Just above the line saying “/* That’s all, stop editing! Happy blogging. */“
Scheduling System Cron for WordPress
You have disabled your wp-cron now what? You need to need to schedule wp-cron.php in your server. Lets see how can we do that.
If you hosting provider is using Cpanel you can create a cron job from the Cpanel. Please make sure you have already disabled the cron in WordPress as told earlier.
Creating a cron jon in Cpanel
Login to your Cpanel and under advance section you will see cron jobs
Select the number of times wp-cron should trigger.
Once you click on Cron jobs you will see a screen like below. On this window, under Common settings label you will find may pre-defined cron schedules, you need to select one of the schedules. The most common among these is twice per hour, which you can use for your cron as well.
Set the command or cron path
Now under same window, you will find a field with label “Command“, here just add the path of cron or command
Giving command
For this you have to provide some unix command for the cron, Like in our case it would be
wget -q -O – https://your-domain-name.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1
The part “>/dev/null 2>&1” in the above command disables email notifications to the email id provided to receive notifications.
Giving Path of php and cron
Here you need to provide php path followed by cron path on the same Command label. The path would be like this
/Path of php/ /path of WordPress site/wp-cron.php
For example “/usr/local/bin/ea-php56” /path-to-your-wp-website/wp-cron.php
Third-Party Solution for cron
If you feel this process is complicated or your server don’t provide cron option. You can go with easycron or any other similar website for cron executions