Cronjob 用于安全更新吗?

Cronjob 用于安全更新吗?

我在 ubuntu 服务器 12.04 上创建用于自动安全更新的 cronjob 时遇到了问题。

我将安全源分离到不同的文件中,然后从 cronjob 中执行此操作:

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
apt-get -o Dir::Etc::sourcelist="security-sources.list" -o Dir::Etc::sourceparts="-" update -y
apt-get -o Dir::Etc::sourcelist="security-sources.list" -o Dir::Etc::sourceparts="-" upgrade -y

但我在日志中收到各种奇怪的消息:

示例 1:

debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
dpkg-preconfigure: unable to re-open stdin:

示例 2:

Unpacking replacement python-apport ...
Preparing to replace apport 2.0.1-0ubuntu15 (using .../apport_2.0.1-0ubuntu15.1_all.deb) ...
stop: Job failed while stopping
invoke-rc.d: initscript apport, action "stop" failed.

示例 3:

Unpacking replacement dh-apparmor ...
Processing triggers for ureadahead ...
Processing triggers for man-db ...
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
Processing triggers for shared-mime-info ...

在我的电子邮件收件箱中收到这些日志后,我通过 ssh 登录并看到了以下内容:

44 packages can be updated.
24 updates are security updates.

所以我猜它没有起作用。

有什么想法吗?

答案1

这实际上不是解决您的脚本问题的答案,但我建议使用无人值守升级安装无人值守升级包。它专门为此而设计。您不必担心在高峰时段更新,因为unattended-upgrades它会随机延迟运行(最多 30 分钟),否则服务器就会被压垮。

如果您仍想更改更新完成的时间,了解unattended-upgrades中的会很有用cron.daily。您可以cron.daily通过编辑文件来更改执行时间/etc/crontab,有关更多信息,请参阅这个问题


如果你想要更多关于设置自动更新的信息(包括一些如何编写自己的 cron 作业的提示),请参阅Ubuntu 帮助页面上的 AutomaticSecurityUpdates

相关内容