[wp-hackers] wp_cron - odd behavior
jeff at jeffrose.ca
Sat Feb 19 17:24:27 UTC 2011
> Date: Fri, 18 Feb 2011 13:58:33 -0500
> From: Jeremy Clarke <jer at simianuprising.com>
> Subject: Re: [wp-hackers] wp_cron - odd behavior
> To: wp-hackers at lists.automattic.com
> <AANLkTikvpVRUxGzj3sW+X5aX8w1jsjfQEKhfZ=We=uqh at mail.gmail.com>
> Content-Type: text/plain; charset=windows-1252
> This isn't a direct answer to your question but my advice is to set up
> something that logs to a file when your wp-cron-attached function runs.
> found that's the only really safe way to know WTF wp-cron is actually
> It's possible your local server isn't happy about email or something, but
> the first thing your script does is add a line to a debug file then you can
> track what hook fired, when it fired and you can debug whether there is an
> unrelated email or other error causing the failure.
> In terms of the single events, are you sure you're using unique
> slugs/labels? I'm pretty sure you can overwrite a cron event by
> the same name to a new time.
> Also this is something you probably already know but the wp-cron system
> fires when someone visits the site. So without organic traffic (local
> install where it's just you) it will only fire when you load the site
> yourself. If you schedule three events one per hour and come back in three
> hours they will all fire simultaneously, resulting in a different effect
> than what you expected. The result is that it will not behave like in the
> wild and you need to lower the timeframes involved when testing to avoid
> driving yourself nuts. Here's some simple code to add an 'Every Minute'
> timeframe to use when testing:
Thanks for the reply Jeremy, but I haven't even gotten to the part of seeing
the cron / function fire. I'm just adding events to the cron. I do
understand how WP_cron fires at it's first call _AFTER_ the time specified
and plays catch up.
I've got a situation where a user creates a booking/event at say 10:00am on
Tuesday and can choose one or more from One hour, Two hour, one day, 2 days
prior for an email alert. So the jobs should be far enough apart to not
interfere. My function name is unique, and it seems that any single event
can work, but when adding more than one, it's spotty if they get entered.
I like your suggestion of logging to a file, but using NetBeans to step
through code, I can watch it fire. I have not yet traced the execution
through WP_cron to see where my details get lost. Guess that's next.
More information about the wp-hackers