Fixing wp-cron issues

The Product Sync for GBP plugin uses the WordPress cron system to publish and sync your WooCommerce products in the background. That way the performance of your site won't be affected while the plugin is publishing or updating products.

The WordPress cron system is a list of core WordPress and third-party background tasks that are run sequentially when someone visits the site. Each time anyone visits your website, a background task is taken from the stack and processed. If your site is not getting a lot of visitors, the system may get clogged, causing tasks to be delayed. Other issues may also cause the system to get delayed or stop working.

If the system is not working correctly you might have problems syncing products with the plugin.

Getting the system to work correctly is not just important for this plugin, but for your entire site. WordPress itself relies on it, as well as other third-party plugins. If its not working you may run into all kinds of strange issues.

Checking for issues

The plugin will show a warning notice at the top of the settings page if the background task has been delayed for more than an hour:

You can use the WP Crontrol plugin to get a more detailed insight into any issues with the system.

The "Events" page of the WP Crontrol plugin will show if there are issues, and will also show if tasks are delayed or stuck in the queue:

This should give you a clue on what the issue is.

Hooking WP Cron into the server task scheduler

As mentioned before, the system relies on the website actually receiving visitors. If the site doesn't get many visitors the system may get clogged with tasks, causing them to be delayed.

One way around this is setting up an automatically recurring "trigger" to the cron system in your hosting control panel. This will make the system much more dependable and timely. 

An in-depth guide about this can be found in the WordPress Developer Resources.

Basically you want to set up a command that will call the wp-cron.php script every 5 minutes or so:

wget --delete-after http://YOUR_SITE_URL/wp-cron.php<br>

Where you should obviously replace YOUR_SITE_URL with the URL of your site. The --delete-after toggle in the command may look scary but that's there so the command won't save its output, but simply discards it.

Here's an example in DirectAdmin:

Using a third-party cron service

Some WordPress hosting providers may not give you access to the cron jobs section in their control panel. Especially managed WordPress hosting providers such as GoDaddy do not give you control over this. 

Luckily there are (free!) third-party cron services that will trigger the cron script on your website. 

For example cron-job.org, which just relies on voluntary donations. 

You can set up a cron job with them and have it call the following URL every 5 minutes:

http://YOUR_SITE_URL/wp-cron.php <br>
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us