Opened 17 years ago
Closed 17 years ago
#5706 closed defect (bug) (invalid)
Cron is triggered several times instead of just once
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.3.2 |
Component: | General | Keywords: | cron, schedule |
Focuses: | Cc: |
Description
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.
Quick Check: Do you have the Object Cache enabled? (define('EBACLE_CACHE',true) in the wp-config file)
If so, Try disabling it:
in #5199 that was brought up(options cache getting out of sync with database), and as of a result, The Object cache has been removed from 2.4/2.5(Yet others can still load a object cache file if they want to)