Better Cron Setup

Overview

# Top

LifterLMS process numerous actions in the background. These actions include triggering delayed engagements, processing recurring payments, expiring access, and running database upgrades.

These actions are, by default, handled by wp-cron.php which is an imprecise cron alternative in the WordPress core. This alternative makes requests on every page load in order to trigger scheduled actions. This means that if your site doesn’t receive any visitors for a period of time, scheduled actions may be missed.

We recommend using a real cron job via crontab on your server or by using a third-party cron service to make regular requests to wp-cron.php.

Consult your webhost

# Top

Some webhosts have specific documentation or instructions on how to configure a real cron job in place of the default wp-cron.php.

For example, WPEngine has an alternative cron alternative which can be enabled by contacting support: https://wpengine.com/support/wp-cron-wordpress-scheduling/

Please contact your host for more information.

Cron Service

# Top

There are a handful of cron services that you can setup easily.

When configuring a cron service, the url you will want to make requests to will be http://exampledomain.tld/wp-cron.php.

EasyCron

This service has a free plan that allows scheduling of a cron on a 10-minute interval. More frequent requests can be made on paid plans.

setcronjob.com

This service has no free plan.

Crontab

# Top

To create a real cronjob:

SSH to your server.

ssh [email protected]

Open the crontab. If this is the first time, you may be asked to select an editor. We recommend using vim, but that’s just us.

crontab -e

Add a new line to the end of the file, ensuring that you specify the absolute file path to your WordPress install, this will be different depending on your server, below is just an example.

In vim, you will have to enter i to enter insert mode and type.

*/5 * * * * cd /var/www/example.com/public; php -q wp-cron.php

When finished, hit esc to leave insert mode and then type :wq to write and quit

This will ensure your cron is called every 5 minutes.
Hit CTRL X followed by Y to save and exit. Cron will now fire every 5 minutes, regardless of whether or not any visits are received.

Last Updated on
Was this article helpful?