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:
/ * Das ist alles, hören Sie mit der Bearbeitung auf! Happy blogging. * /
enter the following line:
define('DISABLE_WP_CRON', true);
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:
wget -q -O - http://yourdomain.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1
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
Cronjobs can be set up at “all-inkl.com” in the KAS (technical administration). To do this, log into the KAS and you will find the “Tool” link under the navigation on the left and the “Cronjobs” link below it. As in the example below (see picture), you then set up the cronjob on the server.
Update 02/20/2022: I recommend you to set the execution interval to “every minute” and then to “every 15 minutes”. We have currently achieved the best results with this and have fixed error messages such as: “A scheduled event is late” in the website status query. WordPress Dashboard –> Tools –> site health
Conclusion
If you want to ensure regular execution or reduce unnecessary server load, you need a real cronjob.
You want to get the real cronjob done by us for faster loading times on your website?