有没有办法更改更新管理器检查更新的时间?

akg*_*ner 16 update-manager

我看到在哪里设置频率,即每周、每天等,但不知道如何设置它检查的时间。

Oli*_*Oli 11

Apt 更新由名为/etc/cron.daily/apt. /etc/cron.daily包含每天发生但同时发生的几个脚本。为了更改 Update Manager 更新的时间,您需要更改所有更新的时间/etc/cron.daily脚本触发的时间。

为此,您需要编辑/etc/crontab文件:

sudoedit /etc/crontab # or: gksu gedit /etc/crontab
Run Code Online (Sandbox Code Playgroud)

这是一个相当标准的cron文件,看起来应该像这样:

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# 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)

从中我们可以看到cron.daily早上 6 点 25 分的触发器。如果您想在凌晨 4 点开始,您可以将第二行替换为:

0 4    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
Run Code Online (Sandbox Code Playgroud)

如果您需要有关格式的更多帮助,维基百科在 Cron 上一个异常技术页面

  • 这不会设置更新发生的确切时间,因为在实际检查新软件包之前会随机休眠。这样做是为了防止数百万用户同时访问镜像。默认睡眠是在 cron 作业开始后的 0 到 30 分钟之间随机选择的。您可以使用 `APT::Periodic::RandomSleep` APT 配置设置更改最大睡眠时间;最大值为“0”意味着它总是会立即发生(**但请记住为什么会有随机睡眠!**)。 (4认同)