Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

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.

share|improve this answer
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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