Verdant TCS

WP-Cron and vCanopy’s GP-Cron

2 min read

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

At vCanopy, we have GP-Cron, 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 site’s PHP user.

For Example:

gp site vCanopy.com -gpcron-on 15

The above sets GP-Cron to run every 15 minutes on vCanopy.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

These Cron jobs do not run under the root cron, as this would elevate WP PHP processes to root privilege and create a security risk, so you won’t find these in the regular crontab. You will need to check the website’s system user-specific 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.

For example:

sudo su - steveswebs8348

You can also check running just one singular command as follows:

sudo su - {system.user} -c "crontab -l"

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 documentation here:

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

RETURN TO THE ROOT USER 

Once done checking your cron jobs you return to the root user with CTRL+D.

How to list all sites on your server running gp-cron 

To view a list of all sites on a given server using GP-Cron you can run the command below to search each site’s env file for the value cron:true:

grep 'cron:true' /var/www/*/logs/*.env

Here’s an example of what the output will look like:

/var/www/anothergpcrontest.site/logs/anothergpcron.test.site.env:cron:true
/var/www/gpcrontest.site/logs/gpcron.test.site.env:cron:true'

Search the Knowledge Base

New to vCanopy?

Get started with our FREE Core plan today! We bring the software, you bring the hardware.