By default, WordPress triggers cron-jobs to run via its internal cron. This gets triggered by users who are visiting your website.
There are several good reasons why you should change this to run directly from the server instead. Moving cron jobs from WordPress to a more reliable method on the server level not only doesn’t impact the speed of your site, but it’s also more reliable.
Time needed: 5 minutes
With the Servebolt Optimizer plugin installed, you can run the following command in your webroot via SSH to do all of the steps below in one command (please note that this will include the optional step 3):
wp servebolt cron enable
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 fewer 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 to add the cron job.
- Optionally turn off email notifications
If you don’t need email notifications for when cron jobs have been executed, you can select the–newly created–cron job in the list on this page and select “Do not send email” in the drop-down box below. Click the “Update” button at 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.