dubiousjim/dcron

handle system date changes

hcodina opened this issue · 2 comments

Hi,
I have a problematic use case and before i fill a github issue, i would like to know your opinion about it.

Let's say we are the October 11 2018.
I have cron jobs scheduled "@hourly" and "@daily" and everything is correct.

I manually change my system date and i set it to January 01 2000.
I have the impression that my jobs will never be run until October 2018 (18 years to wait).
I expect my job to be scheduled one hour or one day after their last run or at least one hour one day after my date change
but not 18 year.

I would like to known what kind of workaround we can do to handle this use case.

In main.c you handle "big" delta as :

if (dt < -60*60 || dt > 60*60) {
	t1 = t2;
	printlogf(LOG_NOTICE,"time disparity of %d minutes detected\n", dt / 60);
}

Maybe we can add something to fix cl_LastRan + timestamp file, cl_NotUntil values in this block.

What do you think about this idea ?
Do you have any other idea to handle system date changes in order to keep @xxxx jobs scheduled hourly, daily, ... ?

Best regards,
Herve Codina

Sounds good.

We can check timestamp when we read it (ie ReadTimestamps())
It seems a good place to update "invalid" timestamp.

We can plan to force a ReadTimestsamps() also on "big" delta detected in order to update "invalid" timestamp as we detect a potential date change.