Disable WP-Cron for faster load times in WordPress
A cron job is a recurring task that is automated. For certain tasks, a pseudo-cron system is integrated in WordPress. Using a real cronjob to automate WordPress has many advantages.
You want to know how to set up a real cron job for your scheduled WordPress tasks and get faster load times in WordPress?
Here you will find out:
WordPress must work on all possible platforms, operating systems and configurations. Normally, there is no cronjob service installed on the server that performs scheduled tasks. For this reason, the developers of WordPress have created a workaround: The file wp-cron.php in your main folder (root) of WordPress is executed every time someone loads a page. Damit wird geprüft, ob eine geplante Aufgabe ausgeführt werden muss und die Datei führt sie gegebenenfalls aus. WP-Cron is not a true cron job. It’s just what WordPress has developed to simulate what a true system cron does.
Performance issues with WP-Cron
However, in certain cases, this file may become the target of a DOS attack. The caching of plugins can also affect the execution, which leads in extreme cases to a large server load. Then the scheduled tasks may not run properly and on time. Therefore, the constant file processing should be replaced by a real cron job.
The tasks to be performed are stored in the “Crontab” table. The individual tasks are the cronjobs. To be able to start these cron jobs at the previously defined times, the cron system has to run permanently in the background.
The system of WordPress does not run continuously on the server. It is always started when a web page is called up. So WordPress did not integrate a real cron system. To automate certain tasks on a regular basis, WordPress has a pseudo-cron system.
#1 How to disable WP-Cron
First, the script is disabled in WordPress so it does not run every time someone loads one of your pages. Open the file wp-config.php in your main WordPress folder and add in front of the line:
/ * That’s all, stop editing! Happy blogging. * /
enter the following line:
Screenshot of the setting in the “wp-config.php”
#2 This is how you plan for System Cron
When you’ve done that, then set up a real cron job to run the wp-cron.php file. Normally, setting the cron job for every 30 minutes is sufficient for most sites.
Create a cron job in cPanel
Log in to your cPanel and go to the cron job tool.
Then add the following command to run every 30 minutes:
The “yourdomain.com” must of course be replaced by your actual domain name.
Alternatively: Create a cron job in the administration of your provider / hosting
e.g. at the web host / provider: all-incl.-com
The creation of cronjobs can be set up at “all-inkl.com” in the KAS (technical administration). To do this you log in to the KAS and you will find the link “Tool” under the left navigation and below that the link “Cronjobs”. As in the example below (see picture), you then set up the cronjob on the server.
If you want to ensure regular execution or reduce unnecessary server load, you need a real cronjob.