3

I am planning to schedule an hourly task from my wp plugin, as I understand these tasks are triggered by visits to the website.

So for an hourly task I will need at least one visitor hourly.

Does it matter at what time of the hour the visitor comes? For example if there's a visitor at 1:05, and another at 2:55, the 1 and 2hs task wont be missed?

4

As you've noted, cron jobs are only fired when someone visits your website. WordPress checks if they are any events that have been scheduled before 'now' that have not yet occurred - and runs them.

Importantly with events that are recur according to a regularly pattern (say hourly) - their occurrence is relative not absolute. That is, once your event triggers it will be scheduled again in an hour's time (rather than being schedule for 1:05, 2:05, 3:05) - of course with no guarantee that it will actually run in an hours time.

In fact with recurring events WordPress only keeps one occurrence saved. Once that occurrence is trigged it is replaced with the next one.

  • 1
    By cron in the above I'm obviously referring to wp-cron, in case there's any confusion :) – Stephen Harris Apr 18 '12 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.