我从 12.04 升级到 14.04,从那时起,当我通过 SSH 登录时,可用的更新不正确且已过期。使用 12.04 时从未发生过这种情况。
例如:
登录后没有显示任何更新。
退出并重新登录。我现在看到:
25个包可以更新。
15 个更新是安全更新。我更新后退出。然后登录,系统仍然显示:
25个包可以更新。
15 个更新是安全更新。注销并登录,现在查看
需要重新启动系统。
今天第一次登录的输出是
0 个软件包可以更新。
0 个更新是安全更新。
因此我退出并再次登录,现在看到:
1 个包可以更新。
1 个更新是安全更新。
因此我运行它,结果是:
Get:1 http://security.ubuntu.com trusty-security InRelease [65.9 kB]
Get:2 http://security.ubuntu.com trusty-security/main Sources [117 kB]
Get:3 http://security.ubuntu.com trusty-security/restricted Sources [4,035 B]
Get:4 http://security.ubuntu.com trusty-security/universe Sources [37.3 kB]
Get:5 http://security.ubuntu.com trusty-security/multiverse Sources [2,760 B]
Get:6 http://security.ubuntu.com trusty-security/main amd64 Packages [485 kB]
Get:7 http://security.ubuntu.com trusty-security/restricted amd64 Packages [13.0 kB]
Get:8 http://security.ubuntu.com trusty-security/universe amd64 Packages [130 kB]
Get:9 http://security.ubuntu.com trusty-security/multiverse amd64 Packages [4,978 B]
Get:10 http://security.ubuntu.com trusty-security/main i386 Packages [458 kB]
Get:11 http://security.ubuntu.com trusty-security/restricted i386 Packages [12.7 kB]
Get:12 http://security.ubuntu.com trusty-security/universe i386 Packages [130 kB]
Get:13 http://security.ubuntu.com trusty-security/multiverse i386 Packages [5,168 B]
Hit http://security.ubuntu.com trusty-security/main Translation-en
Ign http://us.archive.ubuntu.com trusty InRelease
Hit http://security.ubuntu.com trusty-security/multiverse Translation-en
Hit http://security.ubuntu.com trusty-security/restricted Translation-en
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Get:14 http://us.archive.ubuntu.com trusty-updates InRelease [65.9 kB]
Get:15 http://us.archive.ubuntu.com trusty-backports InRelease [65.9 kB]
Hit http://us.archive.ubuntu.com trusty Release.gpg
Get:16 http://us.archive.ubuntu.com trusty-updates/main Sources [277 kB]
Get:17 http://us.archive.ubuntu.com trusty-updates/restricted Sources [5,352 B]
Get:18 http://us.archive.ubuntu.com trusty-updates/universe Sources [156 kB]
Get:19 http://us.archive.ubuntu.com trusty-updates/multiverse Sources [5,939 B]
Get:20 http://us.archive.ubuntu.com trusty-updates/main amd64 Packages [773 kB]
Get:21 http://us.archive.ubuntu.com trusty-updates/restricted amd64 Packages [15.9 kB]
Get:22 http://us.archive.ubuntu.com trusty-updates/universe amd64 Packages [361 kB]
Get:23 http://us.archive.ubuntu.com trusty-updates/multiverse amd64 Packages [13.2 kB]
Get:24 http://us.archive.ubuntu.com trusty-updates/main i386 Packages [740 kB]
Get:25 http://us.archive.ubuntu.com trusty-updates/restricted i386 Packages [15.6 kB]
Get:26 http://us.archive.ubuntu.com trusty-updates/universe i386 Packages [363 kB]
Get:27 http://us.archive.ubuntu.com trusty-updates/multiverse i386 Packages [13.6 kB]
Hit http://us.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://us.archive.ubuntu.com trusty-updates/multiverse Translation-en
Hit http://us.archive.ubuntu.com trusty-updates/restricted Translation-en
Hit http://us.archive.ubuntu.com trusty-updates/universe Translation-en
Get:28 http://us.archive.ubuntu.com trusty-backports/main Sources [9,551 B]
Get:29 http://us.archive.ubuntu.com trusty-backports/restricted Sources [28 B]
Get:30 http://us.archive.ubuntu.com trusty-backports/universe Sources [35.2 kB]
Get:31 http://us.archive.ubuntu.com trusty-backports/multiverse Sources [1,898 B]
Get:32 http://us.archive.ubuntu.com trusty-backports/main amd64 Packages [13.3 kB]
Get:33 http://us.archive.ubuntu.com trusty-backports/restricted amd64 Packages [28 B]
Get:34 http://us.archive.ubuntu.com trusty-backports/universe amd64 Packages [43.2 kB]
Get:35 http://us.archive.ubuntu.com trusty-backports/multiverse amd64 Packages [1,571 B]
Get:36 http://us.archive.ubuntu.com trusty-backports/main i386 Packages [13.3 kB]
Get:37 http://us.archive.ubuntu.com trusty-backports/restricted i386 Packages [28 B]
Get:38 http://us.archive.ubuntu.com trusty-backports/universe i386 Packages [43.2 kB]
Get:39 http://us.archive.ubuntu.com trusty-backports/multiverse i386 Packages [1,552 B]
Hit http://us.archive.ubuntu.com trusty-backports/main Translation-en
Hit http://us.archive.ubuntu.com trusty-backports/multiverse Translation-en
Hit http://us.archive.ubuntu.com trusty-backports/restricted Translation-en
Hit http://us.archive.ubuntu.com trusty-backports/universe Translation-en
Hit http://us.archive.ubuntu.com trusty Release
Hit http://us.archive.ubuntu.com trusty/main Sources
Hit http://us.archive.ubuntu.com trusty/restricted Sources
Hit http://us.archive.ubuntu.com trusty/universe Sources
Hit http://us.archive.ubuntu.com trusty/multiverse Sources
Hit http://us.archive.ubuntu.com trusty/main amd64 Packages
Hit http://us.archive.ubuntu.com trusty/restricted amd64 Packages
Hit http://us.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://us.archive.ubuntu.com trusty/multiverse amd64 Packages
Hit http://us.archive.ubuntu.com trusty/main i386 Packages
Hit http://us.archive.ubuntu.com trusty/restricted i386 Packages
Hit http://us.archive.ubuntu.com trusty/universe i386 Packages
Hit http://us.archive.ubuntu.com trusty/multiverse i386 Packages
Hit http://us.archive.ubuntu.com trusty/main Translation-en
Hit http://us.archive.ubuntu.com trusty/multiverse Translation-en
Hit http://us.archive.ubuntu.com trusty/restricted Translation-en
Hit http://us.archive.ubuntu.com trusty/universe Translation-en
Ign http://us.archive.ubuntu.com trusty/main Translation-en_US
Ign http://us.archive.ubuntu.com trusty/multiverse Translation-en_US
Ign http://us.archive.ubuntu.com trusty/restricted Translation-en_US
Ign http://us.archive.ubuntu.com trusty/universe Translation-en_US
Fetched 4,499 kB in 5s (775 kB/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
libxml2
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 573 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main libxml2 amd64 2.9.1+dfsg1-3ubuntu4.8 [573 kB]
Fetched 573 kB in 0s (1,256 kB/s)
(Reading database ... 41499 files and directories currently installed.)
Preparing to unpack .../libxml2_2.9.1+dfsg1-3ubuntu4.8_amd64.deb ...
Unpacking libxml2:amd64 (2.9.1+dfsg1-3ubuntu4.8) over (2.9.1+dfsg1-3ubuntu4.7) ...
Setting up libxml2:amd64 (2.9.1+dfsg1-3ubuntu4.8) ...
Processing triggers for libc-bin (2.19-0ubuntu6.9) ...
然后我退出并再次登录,它仍然说
1 个包可以更新。
1 个更新是安全更新。
然后我退出并再次登录,现在它正确地没有显示任何可用的更新。
重申一下 - 问题不在于更新,问题在于可用更新总是被一个登录/注销周期延迟。对我来说完全没有意义!
答案1
由于使用了缓存,您有时会看到旧信息。
我们希望消息是最新的,但我们也不想在确定更新状态时阻止向您提供提示。例如,您可能试图登录以修复导致过多磁盘 I/O 的某些不相关故障;如果您无法快速完成此操作,那将令人沮丧,因为登录坚持在检查更新状态时创建更多磁盘 I/O,而您甚至不关心修复磁盘 I/O 故障。
如果您没有启用自动更新,并且有一段时间没有登录,此消息的目的是提醒您安装更新。如果您刚刚自己安装了更新,或者想要查询最新的准确信息,则应使用apt-get
直接使用。
该消息来自以下update-notifier-common
包裹:/etc/update-motd/90-updates-available
。为了最大限度地缩短登录时间,脚本使用缓存。如果缓存被视为过时,则更新信息。如果缓存不被视为过时,例如如果信息最近更新,则不更新信息。
在 16.04 版本中,我们再次调整了细节,以便完全不减慢登录速度。
答案2
/usr/lib/update-notifier/update-motd-updates-available 的内容是什么?
https://bugs.launchpad.net/ubuntu/+source/update-motd/+bug/766827
评论 #14、#18、#22
(抱歉,我暂时无法发表评论)
答案3
通过此主题我发现解决方案是通过编辑这两个文件来禁用更新消息的缓存:
sshd 配置文件
/etc/pam.d/登录
从此行删除“noupdate”:
session optional pam_motd.so motd=/run/motd.dynamic noupdate
我通常每周登录一次,现在我可以获得更新消息,这些消息可以准确显示当前状态,而不是过时一周。