[wp-trac] [WordPress Trac] #5706: Cron is triggered several times instead of just once

WordPress Trac wp-trac at lists.automattic.com
Tue Jan 22 05:56:20 GMT 2008


#5706: Cron is triggered several times instead of just once
----------------------+-----------------------------------------------------
 Reporter:  Mrasnika  |       Owner:  anonymous     
     Type:  defect    |      Status:  new           
 Priority:  normal    |   Milestone:  2.3.3         
Component:  General   |     Version:  2.3.2         
 Severity:  normal    |    Keywords:  cron, schedule
----------------------+-----------------------------------------------------
 ''A little foreword:''
 I have a custom made plugin which uses the cron/schedule feature of WP. It
 has several "routines" in it, which you can call each 1hrs, 2hrs, 6hrs,
 24hrs, etc. One of these "routines" inserts new posts when a condition is
 met.

 '''The problem:'''
 The cron task is called multiple times when it times has come. This
 results in inserting several identical posts. For example a routine is due
 to run each 6hrs, and insert a post reporting the number of comments that
 were submitted in the last 6hrs. This routine should produce only one post
 like that, while now it varies from 2 to 8. To investigate what the
 problem is I made the "routine" report the time of its execution and
 that's how I identified that wp-cron.php is called multiple times instead
 of just one (the period is 6hrs, and the format is date('Y-m-d-_His') +
 microtime(1)):


 {{{
 2008-01-21_062803.(1200925683.07)
 2008-01-21_080824.(1200931704.85)
 2008-01-21_080825.(1200931705.84)
 2008-01-21_080848.(1200931728.36)
 2008-01-21_080849.(1200931729.83)
 2008-01-21_080850.(1200931730.19)
 2008-01-21_140804.(1200953284.51)
 2008-01-21_140806.(1200953286.05)
 2008-01-21_140815.(1200953295.16)
 2008-01-21_140816.(1200953296.72)
 2008-01-21_140818.(1200953298.95)
 2008-01-21_140818.(1200953298.98)
 2008-01-21_140820.(1200953300.43)
 2008-01-21_140821.(1200953301.45)
 2008-01-21_140821.(1200953301.93)
 2008-01-21_140822.(1200953302.1)
 2008-01-21_140822.(1200953302.67)
 2008-01-21_140822.(1200953302.7)
 2008-01-21_140822.(1200953302.75)
 2008-01-21_140822.(1200953302.81)
 2008-01-21_140823.(1200953303.44)
 2008-01-21_140823.(1200953303.52)
 2008-01-21_140823.(1200953303.69)
 2008-01-21_140823.(1200953303.89)
 2008-01-21_140823.(1200953303.93)
 2008-01-21_140824.(1200953304.53)
 2008-01-21_140824.(1200953304.77)
 2008-01-21_140826.(1200953306.06)
 2008-01-21_140826.(1200953306.51)
 2008-01-21_140826.(1200953306.63)
 2008-01-21_200804.(1200974884.58)
 2008-01-21_200809.(1200974889.21)
 2008-01-21_200813.(1200974893.98)
 2008-01-21_200814.(1200974894.07)
 2008-01-21_200817.(1200974897.98)
 2008-01-21_200818.(1200974898.87)
 2008-01-21_200818.(1200974898.94)
 2008-01-21_200818.(1200974898.96)
 2008-01-21_200819.(1200974899.15)
 2008-01-21_200819.(1200974899.22)
 2008-01-21_200820.(1200974900.53)
 2008-01-21_200820.(1200974900.55)
 2008-01-21_200821.(1200974901.34)
 2008-01-21_200821.(1200974901.82)
 2008-01-21_200821.(1200974901.9)
 2008-01-21_200822.(1200974902.36)
 2008-01-21_200823.(1200974903.17)
 }}}


 You can see how we have multiple "timestamps" recorded for each 6hrs,
 while there should be only one.

 Note, that I checked my "cron" setting in wp_options table and it has no
 excess hooks, but just the ones I use.

 ''Observations:''
 I am not 100% sure but my observations are that this started happening
 after upgrading to 2.3.2; I haven't encountered such issues before that.

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


More information about the wp-trac mailing list