重新启动命令会等待无人值守升级完成吗?

重新启动命令会等待无人值守升级完成吗?

我在计算机上随机运行无人值守升级。我有一个 cron 每天在设定的时间重新启动。如果我的重新启动 cron 在更新过程中运行,它会等待重新启动还是会在安装过程中强制重新启动?

答案1

当您运行rebootinit 系统时,请通过发送 SIGTERM 信号来请求正在运行的进程关闭。如果它们没有在合理的时间内关闭(如果您在使用 systemd 的机器上,则该时间默认为 90 秒),init 系统将发送 SIGKILL 信号。

我们当然不想终止繁忙的无人值守升级过程,因为这可能会导致安装了一半的软件包。开发人员知道完整运行(例如安装同一天发布的许多更新)可能需要 90 秒以上才能完成无人值守升级,因此增加了超时时间。在我的 Ubuntu 20.04 机器上我得到:

$ grep TimeoutStopSec /usr/lib/systemd/system/unattended-upgrades.service 
TimeoutStopSec=1800

即使在较旧的机器上,30 分钟也应该足够了。如果您不想等待那么长时间或者仍然担心无人值守升级运行会被中断,请考虑在 中启用以下参数/etc/apt/apt.conf.d/50unattended-upgrades

// Split the upgrade into the smallest possible chunks so that
// they can be interrupted with SIGTERM. This makes the upgrade
// a bit slower but it has the benefit that shutdown while a upgrade
// is running is possible (with a small delay)
//Unattended-Upgrade::MinimalSteps "true";

相关内容