WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is kind of a stupid question...

I scheduled a action to run every hour:

  wp_schedule_event(time(), 'hourly', 'my_hourly_events');

add_action('my_hourly_events', 'the_function_to_run');

function the_function_to_run(){
   echo 'it works!'; 

How can I test if this works without waiting an hour? :)

I tried adding wp_clear_scheduled_hook('my_hourly_events'); before this code and adding wp_cron() after, but I don't see my function running...


ok, I added a trigger_error() inside my function, checked out the apache error log, and it's there :)

So now I'm even more confused:

  • How can the wp-cron run in the background? because apparently that's what happens if I see no output...

  • this doesn't seem to work in a object context; why?

share|improve this question
ok I found out the wp-cron.php is being executed with wp_remote_post(). that explains everything... – onetrickpony Apr 10 '11 at 23:33
By "object context", do you mean your callback is like array( &$this, 'my_method_name' )? That will indeed not work because the function name is stored in the database to be executed later. &$this refers to a specific object, not a class name, and this object will not exist at the next request when the cron job is executed. A static class function should work. – Jan Fabry Apr 11 '11 at 9:34
yes, I had to make my function static. I didn't think wp would remotely run a local script as "cron" – onetrickpony Apr 11 '11 at 17:05
up vote 17 down vote accepted

My favorite plugin for that is Core Control which has very nice module for display of what is going in the cron - which events are set up, when are they next firing, etc.

On getting your hands dirty level see _get_cron_array(), which returns internal stored data for cron events (top level of keys are timestamps).

share|improve this answer
very useful plugin! – onetrickpony Apr 11 '11 at 17:06
does the HTTP Access Logger log all requests or just the ones made with WP's HTTP api? This is great for finding requests plugins make and why your page is loading slow :) – onetrickpony Apr 11 '11 at 17:12
@One Trick Pony not sure, but it would make sense to assume it's API only – Rarst Apr 11 '11 at 17:27

Your Answer


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.