以编程方式禁用 apt 无人值守升级

以编程方式禁用 apt 无人值守升级

我如何以编程/脚本方式禁用 apt 无人值守升级?运行 Ubuntu 16.04。

答案1

有几种方法:

方法一

  1. unattended-upgrades通过在文件中重新配置来关闭自动升级/etc/apt/apt.conf.d/50unattended-upgrades

    • 注释掉Unattended-Upgrade::Allowed-Origins规则集中的个别行:-

      Unattended-Upgrade::Allowed-Origins {
          "${distro_id}:${distro_codename}-security";
          //      "${distro_id}:${distro_codename}-updates";
          //      "${distro_id}:${distro_codename}-proposed";
          //      "${distro_id}:${distro_codename}-backports";
      };
      
  2. 通过将包名称添加到“Unattened-Upgrade:Package-Blacklist”规则集,有选择地在包级别禁用自动更新:

    Unattended-Upgrade::Package-Blacklist {
        //      "vim";
        //      "libc6";
    };
    

方法二

  1. 从文件中禁用系统范围的自动更新/etc/apt/apt.conf.d/10periodic

    • sudo nano /etc/apt/apt.conf.d/10periodic

      APT::Periodic::Update-Package-Lists "1";
      APT::Periodic::Download-Upgradeable-Packages "0";
      APT::Periodic::AutocleanInterval "0";
      APT::Periodic::Unattended-Upgrade "0"; <--- line of interest, should be "0"
      

方法三:

前往Ubuntu Software Center,,Edit --> Software Sources选择NeverAutomatically check for update

在此处输入图片描述

来源(包括图片):

http://ask.xmodulo.com/disable-automatic-updates-ubuntu.html

答案2

更简单、更不易碎的方法(我认为比更不易碎apt remove unattended-upgrades)是:

cp  /usr/share/unattended-upgrades/20auto-upgrades-disabled  /etc/apt/apt.conf.d/

我已经通过查看验证了这一点/var/log/unattended-upgrades/unattended-upgrades.log

答案3

您可以删除需要 dpkg 锁的无人值守升级:

$ sudo apt-get remove unattended-upgrades

或者只是通过配置禁用它:

$ sudo vim /etc/apt/apt.conf.d/10periodic

并确保此行具有零值:

APT::Periodic::Unattended-Upgrade "0";

相关内容