16

Recently, I've noticed that when I run sudo apt update, an extra 6 lines are written to my syslog each time:

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.

In addition, I can see that apt-news.service and esm-cache.service are both dated 2023-01-19, which means they're relatively new services introduced on my system.

I believe that these services are making noise in my syslog, and aren't really needed for my machine. So how can they be disabled so they don't trigger each time you use apt update?

Artur Meinild
  • 26,018

1 Answers1

22

Let's explore the service files to see what info is available:

$ 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

The esm-cache.service is a little more generous with information about its purpose, while the apt-news.service don't really clarify much. However, 'APT News' was mentioned recently in another question, and one can conclude that it's connected to this apt prompt.

Inspecting the apt history further, it seems these services were installed with ubuntu-advantage-tools version 27.13.X. (For me, this was rolled out with version 27.13.1 on 2023-01-27 for arm64 and with version 27.13.2 on 2023-01-29 for x64.)

Since these services seem to only provide additional information in connection to running apt (and pro security-status), they should be safe to disable.

This is done by simply masking the service units from systemd, like this:

$ sudo systemctl mask apt-news.service
$ sudo systemctl mask esm-cache.service

In addition, you can disable the entire apt ESM hook by doing the following: (Thanks 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

(Please note that the --rename option can be omitted on Ubuntu 22.04 and later, since this is now the default.)

By moving this file, the entire apt ESM hook is disabled and will never run. The dpkg-divert will ensure that this file will always be redirected, even when ubuntu-advantage-tools are upgraded and tries to install the file again.

Artur Meinild
  • 26,018