如果Cron的作业计划在凌晨2点运行,凌晨3点运行,那么这些作业如何受到夏令时的影响?
当时间移回一小时时,时间是从凌晨2:59:59直到凌晨2:00:00?这意味着2 am工作将运行两次,3 am工作将运行一次?或者是时间先更改为3:00:00,然后是2:00:00,导致两个作业都运行两次?
当时间向前移动时小时的时间是从1:59:59 am到3:00:00,导致2 am作业不运行,3 am作业运行一次?或者时间是从2:00:00到3:00:00,这两个作业都运行一次吗?
总之,我想知道的是,小时是3小时发生一次或两次,而丢失一小时,2小时发生。我在Google上查找时找不到任何内容。
解决方案答案将取决于变体/的cron你正在使用。某些变体不处理夏令时,导致缺少作业和两次运行作业。
如果您使用的是Paul Vixie cron,那么它会处理DST更改。根据 cron手册页:
>此外,关于夏令时(第二段清楚解释你的回答)
夏令时和其他时间更改
当地时间更改少于三小时,例如由夏令时的开始或结束,将被特别处理。此仅适用于在特定时间运行的作业和运行的作业,其粒度大于1小时。正常运行更多fre- 的作业。 如果时间向前移动,那些将在已经跳过的inter- val中运行的作业将立即运行。相反,如果时间向后移动,则要注意避免运行两次作业。 超过3小时的时间更改被认为是对时钟或时区的的更正,并且新的时间立即使用。
因此,每当时间偏移可能是2:59:59或在3:00:00,cron的照顾工作通过处理情况运行,只运行错过的,避免运行已经运行的作业。
If Cron has a job scheduled to run at 2 am and one at 3 am how would those jobs be affected by daylight savings time?
When the time shifts back an hour does the time go from 2:59:59 am to 2:00:00 am directly? Meaning that the 2 am job would run twice and the 3 am job would run once? Or is does the time first change to 3:00:00 am and then 2:00:00 am causing both jobs to run twice?
When the time shifts forward an hour does the time go from 1:59:59 am to 3:00:00 am causing the 2 am job to not run and the 3 am job to run once? Or does the time shift from 2:00:00 to 3:00:00 am causing both jobs to run once?
In short what I am wondering is when gaining an hour does the 3 am hour happen once or twice and and losing an hour does the 2 am hour happen at all. I have not been able to find anything about this when looking on Google.
解决方案The answer would be dependent on the variant/extension of cron you are using. Some variant's do not handle the Daylight Saving Time, leading to missing jobs and twice run of the job.
If you are using the Paul Vixie cron, then it does handle the DST changes. As per the cron man page:
cron checks each minute to see if its spool directory's modtime (or the modtime on /etc/crontab) has changed
And further, with reference to Daylight Saving Time (The 2nd para clearly explains your answer)
Daylight Saving Time and other time changes
Local time changes of less than three hours, such as those caused by the start or end of Daylight Saving Time, are handled specially. This only applies to jobs that run at a specific time and jobs that are run with a granularity greater than one hour. Jobs that run more fre- quently are scheduled normally. If time has moved forward, those jobs that would have run in the inter- val that has been skipped will be run immediately. Conversely, if time has moved backward, care is taken to avoid running jobs twice. Time changes of more than 3 hours are considered to be corrections to the clock or timezone, and the new time is used immediately.
So, whenever the time shift's may be 2:59:59 or at 3:00:00, cron's taking care of the job runs by handling the situation and running only the missed ones and avoid's running the already ran jobs.
更多推荐
夏令时和Cron
发布评论