/etc/crontab 中设置的默认时间背后的故事是什么?

Der*_*ler 20 default cron

据我了解,这是默认配置/etc/crontab

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
Run Code Online (Sandbox Code Playgroud)

为什么为默认条目选择这些特定时间?

起初我认为它们在安装时有些随机化以平衡系统负载,但这似乎并不正确。

der*_*ert 22

Ubuntu 始于 2004 年,基于 Debian。到那时,当前的 crontab 已经存在,因此我们可以追溯 Debian 历史以找到它的起源。

这是来自 Debian 0.93R6(1995 年 11 月)的 crontab。小时存在,但 cron.daily 条目的分钟不同:

# m h dom mon dow user  command
42 6    * * *   root    run-parts /etc/cron.daily
47 6    * * 7   root    run-parts /etc/cron.weekly
52 6    1 * *   root    run-parts /etc/cron.monthly
Run Code Online (Sandbox Code Playgroud)

到 Debian 2.1(2009 年 3 月 9 日),情况发生了变化。cron.hourly 条目尚不存在,但其余时间与当前相同:

25 6    * * *   root    run-parts --report /etc/cron.daily
47 6    * * 7   root    run-parts --report /etc/cron.weekly
52 6    1 * *   root    run-parts --report /etc/cron.monthly
Run Code Online (Sandbox Code Playgroud)

谢天谢地,Debian 有更新日志,所以我们可以看到为什么要进行这个更改。我已经链接了错误号,幸运的是 Debian 保留了它:

  • 早点做 cron.daily,尽量避免与 cron.weekly 重叠(关闭:Bug#23023)(从 3.0pl1-46)

现在,找出早上 6 点和 47 点和 52 点的来源,您将不得不追溯 Debian 之前的历史。我检查了原始的 Vixie Cron 来源,它似乎不是从那里来的。

据我所知,SLS 1.03没有发布 cron,但SLS 1.05 发布了。但是,它似乎没有附带 /etc/crontab,并且联机帮助页中的示例有所不同。它也没有run-parts.

查看来自 Debian 0.93R6(包 miscutils)的运行部分,它似乎是一个 Debian 特定的工具(当时是一个简短的 Perl 脚本)。所以那些 cron 行可能来自于非常早期的 Debian 开发。