[wp-trac] [WordPress Trac] #11046: wp_schedule_event happens multiple times (wp cron)

WordPress Trac wp-trac at lists.automattic.com
Thu Oct 29 16:23:54 UTC 2009


#11046: wp_schedule_event happens multiple times (wp cron)
--------------------------+-------------------------------------------------
 Reporter:  mdgross       |       Owner:  westi     
     Type:  defect (bug)  |      Status:  new       
 Priority:  normal        |   Milestone:  Unassigned
Component:  Cron          |     Version:  2.7.1     
 Severity:  blocker       |    Keywords:            
--------------------------+-------------------------------------------------
 wp_schedule_event is occurring frequently between scheduled intervals. I
 have it set to record its execution time every ten minutes.

 In a plugin file:

 {{{
 add_filter('cron_schedules', 'more_reccurences');
 add_action( 'happens_every_ten_minutes', 'do_this_every_ten_minutes' );

 function more_reccurences() {
         return array('tenmin' => array('interval' => 600, 'display' =>
 'Every Ten Minutes'));
 }

 if (!wp_next_scheduled('happens_every_ten_minutes')) {
         wp_schedule_event( time(), 'tenmin', 'happens_every_ten_minutes'
 );
 }

 function do_this_every_ten_minutes() {
         $times = get_site_option('zzz-every_ten_minutes', array());
         $times[] = date('g:i:s A');
         update_site_option('zzz-every_ten_minutes', $times);
 }

 }}}
 On a template page:

 {{{
 foreach(get_site_option('zzz-every_ten_minutes') as $execution_time) {
         echo $execution_time . '<br />';
 }
 }}}

 The result of recording execution time at ten minute intervals is:


 {{{
 8:34:56 PM
 8:34:59 PM
 8:35:04 PM
 8:35:12 PM
 8:35:17 PM
 8:35:28 PM
 8:35:33 PM
 8:35:39 PM
 8:35:47 PM
 8:36:06 PM
 8:36:07 PM
 8:36:27 PM
 8:36:48 PM

 }}}

 As you can see the event is happening much more frequently than every ten
 minutes... what is going on here?

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/11046>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list