Score:11

What are the services 'apt-news' and 'esm-cache', and how do I disable them?

vn flag

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?

Score:14
vn flag

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.

user535733 avatar
cn flag
Looks like these services are seen only by Ubuntu Pro subscribers.
MarcoZen avatar
cn flag
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.
Kelly Roadkill avatar
in flag
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](https://bugs.launchpad.net/ubuntu/+source/ubuntu-advantage-tools/+bug/2004130)). Cheers!
bvargo avatar
cn flag
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 https://ubuntu.com/esm"
br flag
@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...
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.