#11046 closed defect (bug) (invalid)
wp_schedule_event happens multiple times (wp cron)
| Reported by: | mdgross | Owned by: | westi |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Cron API | Version: | 2.7.1 |
| Severity: | blocker | Keywords: | |
| Cc: | Focuses: |
Description
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?
Change History (2)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)