如何在 Ubuntu 16.04 上禁用每日升级和清理

如何在 Ubuntu 16.04 上禁用每日升级和清理

我刚刚更新到 Ubuntu 16.04 并且遇到了中断,我将其追溯到运行无人值守升级(顺便关闭了 tomcat 服务器)。

我想禁用所有无人值守升级,以便当服务器不处于任务关键状态时可以手动运行它们。

我在 /var/log/syslog 中看到此行

Jun  1 06:27:23 www3 systemd[1]: Started Daily apt upgrade and clean activities.

我该如何阻止该进程运行?

答案1

起初我尝试过:

sudo apt-get remove unattended-upgrades

但这还不够。我还必须这样做:

sudo systemctl stop apt-daily.timer
sudo systemctl disable apt-daily.timer
sudo systemctl disable apt-daily.service
sudo systemctl daemon-reload

答案2

只是补充一下,首先可以列出任务:

sudo systemctl list-timers

找到 apt-daily-upgrade.timer,然后禁用它

sudo systemctl stop apt-daily-upgrade.timer
sudo systemctl disable apt-daily-upgrade.timer
sudo systemctl daemon-reload

答案3

喜欢vaclav.blazek回答,但您不必删除它,而是可以修改它。

基于本文档,您可以更改 中可用的选项/etc/apt/apt.conf.d/20auto-upgrades

// Do "apt-get update" automatically every n-days
// (0=disable, 1=1 day, 7= 1 week)
// Check new update.
APT::Periodic::Update-Package-Lists "0";

// Do "apt-get upgrade --download-only" every n-days
// (0=disable, 1=1 day, 7= 1 week)
// Download new update.
APT::Periodic::Download-Upgradeable-Packages "0"

// Do "apt-get autoclean" every n-days
// (0=disable, 1=1 day, 7= 1 week)
// Clean old updates.
APT::Periodic::AutocleanInterval "0";

// Run the "unattended-upgrade" security upgrade script
// every n-days 
// (0=disable, 1=1 day, 7= 1 week)
// Requires the package "unattended-upgrades" and will write
// a log in /var/log/unattended-upgrades
APT::Periodic::Unattended-Upgrade "0";

因此,如果您想要的场景是仅在每日更新时通知,它将看起来像:

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "0";
APT::Periodic::AutocleanInterval "0";
APT::Periodic::Unattended-Upgrade "0";

因此,如果您想要的场景是在每日升级时下载而不升级,它将看起来像这样:

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "0";
APT::Periodic::Unattended-Upgrade "0";

或者,如果你想手动完成所有操作,也就是禁用它,它看起来像这样:

APT::Periodic::Update-Package-Lists "0";
APT::Periodic::Download-Upgradeable-Packages "0";
APT::Periodic::AutocleanInterval "0";
APT::Periodic::Unattended-Upgrade "0";

基本上,将其全部归零即可。

有两个文件包含配置,分别是:

  • /etc/apt/apt.conf.d/10periodic; 和
  • /etc/apt/apt.conf.d/20auto-upgrades

因此,请检查两个文件以确保配置符合您的需要。

我希望这对你有帮助。

答案4

我只是删除了无人值守升级包。

相关内容