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

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.
 
Cron tasks can only be run when a user visits the forum.
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:
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.
 
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?
 
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?
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:
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.
 
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.
 
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.
 
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.
 
Top Bottom