1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Cannot Reproduce Cron task next scheduled run time resetting to random times

Discussion in 'Resolved Bug Reports' started by Snog, Oct 14, 2013.

  1. Snog

    Snog Well-Known Member

    I've observed this on every cron task on my system (running XF 1.2.2). But it is most apparent with tasks that are set to run every 5 minutes with these settings:

    Day of the Month: Any
    Run at hours: Any
    Run at minutes: 0,5,10,15,20,25,30,35,40,45,50,55
    Allow cron entry to run automatically when scheduled is checked.

    If the cron is left to run automatically, after it runs, the next scheduled run time is sometimes correct and others it is a random value sometimes up to 2 hours later than it should be.
  2. tyteen4a03

    tyteen4a03 Well-Known Member

    Cron tasks can only be run when a user visits the forum.
  3. Snog

    Snog Well-Known Member

    I know that.

    I'm saying AFTER the task has run, the NEXT run time is incorrect.

    In the example I gave, say the task runs at 12:05pm (forced by refreshing the page). After it runs, the next run time will be set to 2:10pm instead of 12:10pm like it should be.

    It doesn't seem to happen all of the time, but it happens often enough that it's noticeable.
    Last edited: Oct 15, 2013
  4. Snog

    Snog Well-Known Member

    I just had this happen again. Task was to run at 7:40. Refreshed forum screen until the task ran. After running, the next run time is shown as 8:45 when it should be 7:45.
  5. Mike

    Mike XenForo Developer Staff Member

    Thus far, I've been unable to reproduce this. I've analyzed the code and though it did take me a bit of time to understand it, I'm not seeing an obvious reason why this would happen.

    Is there any rhyme or reason to when it happens?
  6. Snog

    Snog Well-Known Member

    I wish there was something that I could say is causing it. But I haven't found the cause either. I can sit and replicate it over and over again without a problem.

    It happens on both my live site and my development server and they are running different PHP versions so it's not PHP specific. Right now I don't have the time to do it, but sometime next week I'll put a few traps in to see if I can catch where it's happening.

    I just checked my development server and it's happened again. One of my custom tasks that should run every 5 minutes is currently displaying the next run time as 5:01pm EDT. And the standard feeder cron is showing 5:02pm EDT when it should be have triggered at 4:02pm EDT. It is currently 4:13pm EDT, so the last run popped an extra hour onto the times.
    Last edited: Oct 25, 2013
  7. Snog

    Snog Well-Known Member

    Something just dawned to me...

    I haven't looked at the code, but is there something in the code that might be trying to compensate for Daylight Savings Time? That would explain the extra hour being added. And since my servers already have the DST time in them and they automatically sync with NTP, it makes me wonder if that's not the problem.
  8. Snog

    Snog Well-Known Member

    I'm not sure why this would make a difference, but changing tasks that have the 'Day of Month' set as 'Any' to use 'Day of Week' - 'Any' seems to correct the problem.

    As I get time I'll research further.
  9. Mike

    Mike XenForo Developer Staff Member

    FWIW, I was testing with "Day of Month" without issue. I don't think that there should be an issue between the DoW and DoM code as it actually runs the same thing.

    DST seems like it could be a possibility, but the date object is created with a timestamp which is automatically UTC and all the calculations are done based on that. Server DST offset shouldn't come into play.
  10. Snog

    Snog Well-Known Member

    Well, again I haven't been able to look at the code yet but now that the servers are off DST and on standard time, all tasks are being marked with the next run time at the proper times.

Share This Page