Art*_*ild 16 apt esm ubuntu-pro
最近,我注意到当我运行时sudo apt update,每次都会向系统日志中写入额外的 6 行:
Jan 29 21:17:01 xb systemd[1]: Starting Update APT News...
Jan 29 21:17:01 xb systemd[1]: Starting Update the local ESM caches...
Jan 29 21:17:02 xb systemd[1]: apt-news.service: Deactivated successfully.
Jan 29 21:17:02 xb systemd[1]: Finished Update APT News.
Jan 29 21:17:02 xb systemd[1]: esm-cache.service: Deactivated successfully.
Jan 29 21:17:02 xb systemd[1]: Finished Update the local ESM caches.
Run Code Online (Sandbox Code Playgroud)
此外,我可以看到apt-news.service和esm-cache.service的日期都是 2023-01-19,这意味着它们是我的系统上引入的相对较新的服务。
我相信这些服务在我的系统日志中产生噪音,并且我的机器并不真正需要这些服务。那么如何禁用它们,这样它们就不会在您每次使用时触发apt update?
Art*_*ild 21
让我们浏览一下服务文件,看看有哪些信息可用:
$ cat /lib/systemd/system/apt-news.service
[Unit]
Description=Update APT News
[Service]
Type=oneshot
ExecStart=/usr/bin/python3 /usr/lib/ubuntu-advantage/apt_news.py
$ cat /lib/systemd/system/esm-cache.service
# The ESM apt cache will maintain information about what ESM updates are
# available to a system. This information will be presented to users in the apt
# output, or when running pro security-status. These caches are maintained
# entirely outside the system apt configuration to avoid interference with user
# definitions. This service updates those caches. This will only have effect
# on releases where ESM is applicable, starting from Xenial: esm-apps for
# every LTS, and esm-infra for systems in expanded support period after the LTS
# expires.
[Unit]
Description=Update the local ESM caches
[Service]
Type=oneshot
ExecStart=/usr/bin/python3 /usr/lib/ubuntu-advantage/esm_cache.py
Run Code Online (Sandbox Code Playgroud)
关于其用途的信息esm-cache.service更加慷慨,但并apt-news.service没有真正澄清太多。不过,最近在另一个问题中提到了“APT News”,可以断定它与此apt提示有关。
进一步检查apt历史记录,这些服务似乎是随ubuntu-advantage-tools版本 27.13.X安装的。(对我来说,这是在 2023 年 1 月 27 日推出的版本 27.13.1,arm64以及在 2023 年 1 月 29 日推出的版本 27.13.2 x64。)
apt由于这些服务似乎只提供与运行(和)相关的附加信息pro security-status,因此应该可以安全地禁用它们。
这是通过简单地屏蔽 中的服务单元来完成的systemd,如下所示:
$ sudo systemctl mask apt-news.service
$ sudo systemctl mask esm-cache.service
Run Code Online (Sandbox Code Playgroud)
此外,您可以apt通过执行以下操作禁用整个 ESM 挂钩:(感谢 Daniel T)
$ sudo dpkg-divert --rename --divert /etc/apt/apt.conf.d/20apt-esm-hook.conf.disabled --add /etc/apt/apt.conf.d/20apt-esm-hook.conf
Run Code Online (Sandbox Code Playgroud)
(请注意,--rename在 Ubuntu 22.04 及更高版本上可以省略该选项,因为这是现在的默认选项。)
通过移动此文件,整个aptESM 挂钩将被禁用并且永远不会运行。这dpkg-divert将确保该文件始终被重定向,即使ubuntu-advantage-tools升级并尝试再次安装该文件也是如此。
| 归档时间: |
|
| 查看次数: |
13043 次 |
| 最近记录: |