By default, WordPress triggers cron-jobs to run via its internal cron. This get triggered by users who are visiting your website.
There are several good reasons why you should change this to run directly from server instead. Moving cron jobs from WordPress to a more reliable method on server level not only doesn’t impact the speed of your site, it’s also more reliable.
Time needed: 5 minutes.
Follow these instructions to set up cron the right way
- Disable WordPress builtin cron trigger
wp-config.phpand add (or uncomment if it already exists)
define( 'DISABLE_WP_CRON', true );
This will make your website spend less resources while users are visiting your website, resulting in faster and more consistent loading times.
- Set up the cron job in the control panel
Go to your site’s cron settings page in the Control Panel and enter the following in the time field:
*/10 * * * *
This will make the cron job run once every 10 minutes.
In the command field, enter the following:
wp cron event run --due-now --path=/kunder/group/user/public/ --quiet
Don’t copy and paste the above directly. Replace the path with the complete path to your public folder. You can find your public path per site in the Control Panel on the main page per site.
Finally click the “Add” button. Now the cron job has been added!
- Optionally turn off email notifications
If you don’t need an email notifications for when cron jobs have been executed, you can select the–newly created–cron job in the list of this page and select “Do not send email” in the drop-down box below. Click the “Update” bottom on the bottom of the page.
Note: you may still receive emails regarding cron jobs, if the cron job that was executed ran into some error. To eliminate these emails you’ll need to fix the underlying errors.