WP-Cron and GridPane’s GP-Cron

1 min read

WP-Cron is how WordPress handles scheduling time-based tasks such as checking for updates and publishing scheduled post. 

At GridPane, we have GPCron, which does the same thing, but at the server level. Unlike WP-Cron, which relies on people visiting your website, you can set it to run at specific time intervals, which assures that things like scheduled posts won’t miss being published.

Using GPCron

The following will setup gpcron to run on your website (it is not on by default). WP cron is disabled and set as a server cronjob with this command:

gp site {site.url} -gpcron-on {minute.interval}

{site.url} is your site.

{minute.interval} is an integer value for minutes, it can be set from 1 to 60 minutes.

The cron will run as a system user cron for your sites PHP user.

For Example:

gp site gridpane.com -gpcron-on 15

The above sets GPCron to run every 15 minutes on gridpane.com

Note

Below shows how to check your cronjob, however, if you need to wish to run any GP-CLI afterwards you will need to logout of (exit) the system user with:

exit

Checking your cronjob

If you want to check that cronjob you can log in to that system user by SSH and check its crontab.

To do that you need to first move into your websites system user and display the crontab:

sudo su - {system.user}
crontab -l

{system.user} is the system user your site belongs to.

If you have run the command correctly, say for 1 minute, you should see the following in your users crontab:

*/1 * * * * wget -q -O - http://{your.site}/wp-cron.php?doing_wp_cron >/dev/null 2>&1

For more information on WP-Cron, you can check out the official documenation here:

https://developer.wordpress.org/plugins/cron/