Suppose I have a CRON job
30 2 * * * ....
Then this would run every time when it is 2:30 at night (local time).
Now suppose I have the time zone Europe/Germany
and it's 2017-10-29 (the day when DST is switched). Then this CRON job would run twice, right?
Suppose I have the time zone Europe/Germany
and the CRON job
30 11 * * * ....
As Germany never had a DST change at 11:30, this will not interfere. But the user could change the local time. To be super clear: This question is NOT about DST.
For the following test cases, I would like to know if/how often the CRON job gets scheduled:
They boil down to How quickly is CRON triggered?, where the 4th one also has the question if CRON stores that it was already executed for that minute.
Another variant of the same question:
The easiest way to answer this with confidence is to take a look at the source for the cron daemon. There are a few versions online like this, or you can use apt-get source cron.
The tick cycle in cron is to repeatedly sleep for a minute, or less if there is a job coming up. Immediately after emerging from the sleep, it checks the time and treats the result as one of these wakeupKind
values:
If in doubt, the source comments these wakeupKind values clearly.
Edit
To follow up on whether sleep()
could be affected by a clock change, it looks like the answer is indirectly there in a couple of the Linux man pages.
nanosleep()
CLOCK_MONOTONIC
clock (even though POSIX.1 says it shouldn't)CLOCK_MONOTONIC
, which explains it is not affected by jumps in the system time, but it would be affected by incremental NTP style clock sync adjustments.So in summary, a system admin style clock change will have no effect on the sleep()
. But for example if an NTP adjustment came in and said to 'gently' advance the clock, cron would experience a series of slightly short sleep()
function calls.