gpt4 book ai didi

cron - 夏令时和 Cron

转载 作者:行者123 更新时间:2023-12-03 07:41:22 28 4
gpt4 key购买 nike

如果 Cron 有一项作业计划在凌晨 2 点运行,另一项作业在凌晨 3 点运行,那么这些作业会受到夏令时的影响吗?

当时间向后移动一小时时,时间是否会直接从凌晨 2:59:59 变为凌晨 2:00:00?这意味着凌晨 2 点的作业将运行两次,凌晨 3 点的作业将运行一次?或者时间是否首先更改为凌晨 3:00:00,然后更改为凌晨 2:00:00,导致两个作业运行两次?

当时间向前移动一小时时,时间会从凌晨 1:59:59 变为凌晨 3:00:00,导致凌晨 2 点作业无法运行而凌晨 3 点作业运行一次吗?或者时间从凌晨 2:00:00 转移到 3:00:00 是否会导致两个作业都运行一次?

简而言之,我想知道的是,当增加一个小时时,凌晨 3 点是否会发生一次或两次,而减少一个小时时,凌晨 2 点是否会发生。我在 Google 上搜索时没有找到任何相关信息。

最佳答案

答案取决于您使用的 cron 的变体/扩展。某些变体不处理夏令时,导致作业丢失和作业运行两次。

如果您使用 Paul Vixie cron,那么它确实会处理 DST 更改。根据cron man page :

cron checks each minute to see if its spool directory'smodtime (or the modtime on /etc/crontab) has changed

此外,引用夏令时(第二段清楚地解释了您的答案)

Daylight Saving Time and other time changes

Local time changes of less than three hours, such as those caused bythe start or end of Daylight Saving Time, are handled specially. Thisonly applies to jobs that run at a specific time and jobs that are runwith 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 timehas moved backward, care is taken to avoid running jobs twice.

Time changes of more than 3 hours are considered to be corrections tothe clock or timezone, and the new time is used immediately.

因此,每当时间变化可能是 2:59:59 或 3:00:00 时,cron 就会通过处理情况并仅运行错过的作业来处理作业,并避免运行已经运行的作业。

关于cron - 夏令时和 Cron,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13195999/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com