2012-11-02 101 views
34

如果克朗的工作計劃在凌晨2點和凌晨3點運行一次,這些工作將如何受到夏令時的影響?夏令時和克朗

當時間倒退一個小時時間從上午2:59:59直到2:00:00 am直接?這意味着上午2點的工作會運行兩次,上午3點的工作會運行一次?或者是第一次變爲3:00:00然後2:00:00導致兩個作業運行兩次?

當時間向前移動一個小時,時間從上午1:59:59到凌晨3:00:00,導致凌晨2點的工作不運行,上午3點的工作運行一次?還是從2:00:00到3:00:00這段時間會導致兩個作業運行一次?

簡而言之,我想知道的是,在一小時內發生一到兩個小時,一小時發生一兩個小時,而在一小時內發生一小時時間就會發生。在Google上查看時,我一直無法找到任何相關信息。

回答

35

答案將取決於您使用的cron的變體/擴展。某些變體不處理夏令時,導致缺少工作和兩次工作。

如果您使用的是Paul Vixie cron,那麼它會處理DST更改。具體根據cron man page

的cron檢查以查看每分鐘如果假脫機目錄的 modtime(或開/ etc/crontab中的modtime)已經改變

並且進一步地,參照夏令時(第2段清楚地解釋你的答案)

夏令時和其他時間的變化

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. 

因此,每當時間轉移可能是2:59:59或在3:00:00,克朗的照顧工作運行處理的情況,只運行錯過的,並避免運行已經運行的工作。

+1

鏈接已損壞。 Paul Vixie克朗。我在互聯網上找不到任何東西。 –

+1

下面是不存在頁面存檔的鏈接:https://web.archive.org/web/20130905110602/http://unixhelp.ed.ac.uk/CGI/man-cgi?cron + 8這是一個託管linux手冊頁的當前網站:https://linux.die.net/man/8/cron –