RecurringJobManager drift over the time

recurring
Tags: #<Tag:0x00007f499aa5f5d8>

#1

Hello guys,

I found out that over the time passes, a time drift happens.

RecurringJobManager manager = new RecurringJobManager();
manager.RemoveIfExists("myjob");
manager.AddOrUpdate("myjob", Job.FromExpression(() => DoWork()), $"0 * * * *", TimeZoneInfo.Local);

In the code above, it’s supposed to execute DoWork method on each hour, e.g. 09:00 pm, 10:00 pm, 11:00 pm, etc. What really happens is that it sometimes executes it at 10:00:09 which is not accurate as much as 10:00:00 is. Is that because the cron expression doesn’t include seconds?


#3

It could have something to do with latency from when the job is enqueued to when it begins processing. My guess is that it’s enqueued at 10:00:00 PM, but begins processing at 10:00:09 PM