Understanding the WP Cron

Matador uses the WordPress Cron feature to manage auto-sync. The way it works is a little confusing, but it is such an important part of how Matador works that we’d love to take a few moments to explain it to you.

First, let’s define “cron.” It’s an acronym for “command run on” and refers to a program that executes tasks on a regular schedule, usually in the context of a Unix-based computer system (like the servers that power most of our web hosts). The tasks are often referred to as “cron tasks” or “cron jobs.”

Fun fact: the term “cron” was derived from the Greek word “chronos,” which means “time.”

Think of them as little alarm clocks that wake up the computer and then tell it to do something. Cron tasks always run on time. It’s like hiring a housekeeper to come to your place and do chores for you, and every night they take out the trash; a cron will always make sure the trash gets taken out. Setting up cron tasks can be difficult and requires advanced access to your server and advanced knowledge of server configuration. When creating Matador, we didn’t expect our users to know how to set up crons, so we didn’t design Matador to use them.

However, we did design Matador to use “WP Cron.” Now, despite the similar name, WP Cron is very different. It is a core feature of WordPress, and it too handles recurring scheduled events. Unlike crons, which run without fail on a regular schedule, a WP Cron runs on the next page load after the scheduled time has passed. So let’s say you live alone and do your own chores, and one of them is to take out the trash every night, but one night you go over to a friend’s place and choose to stay the night. Because you weren’t home to take out the trash, it didn’t get taken out. The same applies to WP Cron. It won’t run the cron unless someone is using the site. We may schedule Matador to sync hourly, but if no one visits your page for three hours (common late at night, for example), the cron won’t run until someone (or a bot) loads the page. Even if we set the schedule to run the cron every 5 seconds, unless a page on the site is loaded every 5 seconds, you’ll never get that frequency.

Since WP Cron runs with page loads, any user, whether it be you or one of your clients, can trigger the cron. Matador’s sync routine, relative to most functions in WordPress, is time-consuming. On PHP 7, WordPress loads in under half a second, but running a Matador sync with Bullhorn can take between 2.5 and 4 seconds. Because some site visitors might abandon a site that loads slowly, we discourage you from having too regular a schedule for your WP cron. That’s why we’ve settled on once hourly.

If you’d like to adjust the frequency of your WordPress cron, to be more regular, You can use an external service like cron-job.org to trigger the run every minute. If you’d like to see how to manually force a sync without waiting for an auto sync, here is a guide on how to do that.

Updated on August 22, 2023

Was this article helpful?

Related Articles

Need Support?
Can't find the answer you're looking for?
Contact Support