无人值守升级

无人值守升级

无人值守升级中有两个具有相同配置设置的文件/etc/apt/apt.conf.d

20auto-upgrades10periodic

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "0";
APT::Periodic::Unattended-Upgrade "1";
  1. 有什么不同?

  2. 为了AutoCleanInterval工作,我是否需要在中设置以下选项/etc/apt/apt.conf.d/50unattended-upgrades

    Unattended-Upgrade::Remove-Unused-Dependencies "true";
    

更新: 不确定这些选项是否有效。在以下测试中,与 apt update 相比,unattended 非常快。我不知道为什么:

abhishek ~ $ time sudo unattended-upgrade -v
[sudo] password for abhishek: 
Initial blacklisted packages: 
Initial whitelisted packages: 
Starting unattended upgrades script
Allowed origins are: ['o=Ubuntu,a=xenial-security', 'o=Ubuntu,a=xenial-updates', 'o=Ubuntu,a=xenial-proposed', 'o=Ubuntu,a=xenial-backports']
No packages found that can be upgraded unattended and no pending auto-removals

real    0m5.108s
user    0m2.840s
sys     0m0.040s

正常更新

abhishek ~ $ time sudo apt update
Hit:1 http://in.archive.ubuntu.com/ubuntu xenial InRelease
Hit:2 http://in.archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:3 http://in.archive.ubuntu.com/ubuntu xenial-backports InRelease
Err:4 https://tiliado.eu/nuvolaplayer/repository/deb xenial InRelease
  Could not resolve host: tiliado.eu
Hit:5 https://packagecloud.io/slacktechnologies/slack/debian jessie InRelease
Hit:6 http://archive.canonical.com/ubuntu xenial InRelease
Get:7 http://security.ubuntu.com/ubuntu xenial-security InRelease [94.5 kB]
Hit:8 http://ppa.launchpad.net/atareao/telegram/ubuntu xenial InRelease                                    
Hit:9 http://ppa.launchpad.net/costales/anoise/ubuntu xenial InRelease
Hit:10 http://ppa.launchpad.net/danielrichter2007/grub-customizer/ubuntu xenial InRelease
Hit:11 http://ppa.launchpad.net/gnumdk/lollypop/ubuntu xenial InRelease
Hit:12 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu xenial InRelease
Hit:13 http://ppa.launchpad.net/gwendal-lebihan-dev/hexchat-stable/ubuntu xenial InRelease
Hit:14 http://ppa.launchpad.net/hanipouspilot/rtlwifi/ubuntu xenial InRelease
Ign:15 http://toolbelt.heroku.com/ubuntu ./ InRelease 
Hit:16 http://ppa.launchpad.net/kivy-team/kivy/ubuntu xenial InRelease
Hit:17 http://ppa.launchpad.net/kubuntu-ppa/backports/ubuntu xenial InRelease
Hit:18 http://ppa.launchpad.net/mc3man/mpv-tests/ubuntu xenial InRelease
Hit:19 http://ppa.launchpad.net/mehanik/ksuperkey/ubuntu xenial InRelease
Hit:20 http://ppa.launchpad.net/nilarimogard/webupd8/ubuntu xenial InRelease
Hit:21 http://ppa.launchpad.net/noobslab/apps/ubuntu xenial InRelease
Hit:22 http://toolbelt.heroku.com/ubuntu ./ Release               
Hit:24 http://apt.nylas.com/ubuntu vivid InRelease
Hit:25 http://ppa.launchpad.net/peterlevi/ppa/ubuntu xenial InRelease
Hit:26 http://ppa.launchpad.net/qbittorrent-team/qbittorrent-stable/ubuntu xenial InRelease
Err:27 http://repository.spotify.com stable InRelease
  Temporary failure resolving 'repository.spotify.com' [IP: 54.235.176.26 80]
Err:28 http://ppa.launchpad.net/tuxonice/ppa/ubuntu xenial InRelease
  Unable to connect to ppa.launchpad.net:http: [IP: 54.235.176.26 80]
Err:29 http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu xenial InRelease
  Unable to connect to ppa.launchpad.net:http: [IP: 54.235.176.26 80]
Err:30 http://ppa.launchpad.net/webupd8team/sublime-text-3/ubuntu xenial InRelease
  Unable to connect to ppa.launchpad.net:http: [IP: 54.235.176.26 80]
Fetched 94.5 kB in 3min 47s (415 B/s)
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.
W: Failed to fetch http://repository.spotify.com/dists/stable/InRelease  Temporary failure resolving 'repository.spotify.com' [IP: 54.235.176.26 80]
W: Failed to fetch https://tiliado.eu/nuvolaplayer/repository/deb/dists/xenial/InRelease  Could not resolve host: tiliado.eu
W: Failed to fetch http://ppa.launchpad.net/tuxonice/ppa/ubuntu/dists/xenial/InRelease  Unable to connect to ppa.launchpad.net:http: [IP: 54.235.176.26 80]
W: Failed to fetch http://ppa.launchpad.net/ubuntu-wine/ppa/ubuntu/dists/xenial/InRelease  Unable to connect to ppa.launchpad.net:http: [IP: 54.235.176.26 80]
W: Failed to fetch http://ppa.launchpad.net/webupd8team/sublime-text-3/ubuntu/dists/xenial/InRelease  Unable to connect to ppa.launchpad.net:http: [IP: 54.235.176.26 80]
W: Some index files failed to download. They have been ignored, or old ones used instead.

real    3m51.729s
user    0m4.140s
sys     0m0.764s

答案1

干得好:

  • 内容之间没有区别,只是由于 的升序解析行为,10periodic会比 更早解析。如果在两个不同的文件(或更多)中提到了相同的指令,则较早的指令将被最后一个指令覆盖。20auto-upgradesapt

  • 不。

    APT::Periodic::AutocleanInterval/var/cache/apt/archives采取一个整数值并设置删除和中的本地缓存包的间隔/var/cache/apt/archives/partial,因此它类似于sudo apt-get clean

    另一方面,Unattended-Upgrade::Remove-Unused-Dependencies采用布尔值并且类似于命令sudo apt-get autoremoveie 将删除任何已安装包未使用的所有依赖项。


要启用Unattended-Upgrade,您需要有以下指令:

APT::Periodic::Unattended-Upgrade

任何文件中的定义都位于Unattened-Upgrade定义之前(例如,定义通常放在中/etc/apt.conf.d/50unattended-upgrades)。

示例值如下:

APT::Periodic::Unattended-Upgrade "1"; ## Runs "Unattened-Upgrade" daily
APT::Periodic::Unattended-Upgrade "7"; ## Runs weekly

至于何时apt运行这个(和其他),它每天运行,并且操作在文件中定义/etc/cron.daily/apt

在我的系统上,cron文件于/etc/cron.daily/上午 06:26 开始运行:

25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )

相关内容