如何轻松中止无人值守升级或对其进行配置,以便在使用 apt-get 升级时自动中止?

如何轻松中止无人值守升级或对其进行配置,以便在使用 apt-get 升级时自动中止?

在 Debian11/KDE 上尝试升级软件包时(以及更早版本sudo apt-get update),它会显示以下错误消息:

Cannot get the exclusive lock on the package backend.
Please close any other legacy packaging tools that may be open.

E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process {id} (unattended-upgr)
W: Be aware that removing the lock file is not a solution and may break your system.
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?

在进程管理器(KSysguard)中,进程树如下所示:

apt.systemd.dai->apt.systemd.dai->无人值守-upgr->无人值守-upgr->无人值守-upgr

当我尝试在 KSysGuard 中“结束进程”时,它只会重新启动(无论如何这都不是解决方案)。该过程在一段时间后完成,但仍有尚未实施的安全更新,因此我不确定它的作用/它如何有用。

dist-upgrade 后我也遇到了这个问题

如何中止无人值守升级或对其进行配置,以便在使用 apt-get 升级时自动中止?我认为更新软件包应该尽可能容易(默认情况下),对于那些刚刚开始使用 GNU/Linux 或不感兴趣花时间解决突然更新问题的人来说,某些阻止更新的东西可能是一个问题由于未知原因而工作。有些人建议手动(通过命令)暂时停止(甚至需要重新启动)或永久删除无人值守升级包。

关于永久删除 unattended-upgr,我认为在后台升级软件包会很有用,但 unattended-upgr 实际上是这样做的吗?

无论如何,如果这不是一个错误或 Debian 默认配置的问题,目前它似乎会降低用户友好性/便利性/UX。

答案1

可以unattended-upgrades在关闭过程中执行,让您可以apt随时执行而不是中止apt进程。

在您的中启用此选项/etc/apt/apt.conf.d/50unattended-upgrades

Unattended-Upgrade::InstallOnShutdown "true";

cat /etc/apt/apt.conf.d/50unattended-upgrades

// Install all updates when the machine is shutting down
// instead of doing it in the background while the machine is running.
// This will (obviously) make shutdown slower.
// Unattended-upgrades increases logind's InhibitDelayMaxSec to 30s.
// This allows more time for unattended-upgrades to shut down gracefully
// or even install a few packages in InstallOnShutdown mode, but is still a
// big step back from the 30 minutes allowed for InstallOnShutdown previously.
// Users enabling InstallOnShutdown mode are advised to increase
// InhibitDelayMaxSec even further, possibly to 30 minutes.
//Unattended-Upgrade::InstallOnShutdown "false";

相关内容