12

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?

1 Answer 1

16

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 gatomon & Kelly)

$ sudo mv /etc/apt/apt.conf.d/20apt-esm-hook.conf /etc/apt/apt.conf.d/20apt-esm-hook.conf.disabled

Now, the services never run anymore, and the entire apt ESM hook has been disabled.

Important notice

Automatic update of ubuntu-advantage-tools can break this configuration, and in addition a condition can be introduced where ubuntu-advantage-tools are not properly configured after an automatic update if the 20apt-esm-hook.conf file is moved.

In this case, it is advised to install ubuntu-advantage-tools manually again to get it properly configured:

sudo apt install ubuntu-advantage-tools

After this, it may be necessary to configure the apt ESM hook to be disabled again.

5
  • 1
    Looks like these services are seen only by Ubuntu Pro subscribers.
    – user535733
    Jan 29 at 22:19
  • 6
    For noobs, 'mask' will be better than 'disbale' as disable can be re-activated anytime by another process. Masked units need to be 'unmasked' before they can be reactivated.
    – MarcoZen
    Jan 31 at 1:23
  • 1
    A small addition to your excellent guide: according to man apt.conf, files in fragment directories which end with .disabled, ~, .bak or .dpkg-[a-z]+ are silently ignored. So, renaming the offending hook into 20apt-esm-hook.conf.disabled should be sufficient (couldn't test it myself, as the latest ubuntu-advantage-tools seems to have this fixed). Cheers! Feb 7 at 1:30
  • I don't remember if I actually masked the services, but I moved the hook: .rw-r--r-- 450 root 27 Jan 18:14 ~20apt-esm-hook.conf and I got this today: "12 additional security updates can be applied with ESM Apps. Learn more about enabling ESM Apps service at ubuntu.com/esm"
    – bvargo
    Mar 25 at 1:04
  • @bvargo Was that at login (i.e. in the motd)? This is separate to the apt ESM hook and I've not yet found a way to disable it... Mar 31 at 8:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .