what is firing cron

Well, it isn’t the best tutorial I’ve came across, so I get why you’re confused…

Smashing Magazine has a little bit better tutorial on this subject.

Some quotes from this article that should help you understand how does WP Cron work…

WordPress Cron is what many people refer to as a “pseudo-cron system.” The difference is in how UNIX cron and WordPress Cron take action. A typical UNIX cron system runs in this order:

  • A time tied to an action occurs.
  • Cron runs the action tied to that time.

With WordPress Cron, it works a little differently:

  • A visitor comes to any page on your WordPress website.
  • WordPress Cron checks each cron event to see whether the scheduled time has passed.
  • If the scheduled time for that event has passed, then WordPress Cron executes any actions tied to that event.

So WP Cron is not the same as UNIX cron, but its purpose is very similar.

The biggest problem with WordPress Cron is that it depends on visits – if there are no visits on your site, WP Cron won’t run). That is why some tutorials tell you, that you should set up server’s cron to hit wp-cron.php (it will force WordPress’ cron to run).

So why the times are different?

Let’s assume that:

  • you scheduled an hourly action in WordPress Cron,
  • last time it ran was at 2:15,
  • your server’s cron runs 5 minutes after every hour.

What will happen if there will be no visits on our site from now on?

  • at 3:05 server’s cron forces WP cron run – but WP cron won’t do anything (it should run hourly and it’s only 50 minutes since last run)
  • at 3:15 WordPress cron won’t run – there are no visits
  • at 4:05 server’s cron again forces WP cron run – now it will do the work.

But as you can see, even that this event is scheduled to run hourly, it haven’t been fired for almost 2 hours. Setting server’s cron to run more often will shorten this delay.

Leave a Comment