14

Is there any way to customize the unattended-upgrades results mail in ubuntu?

The current configuration in /etc/apt/apt.conf.d/50unattended-upgrades file -

// Send email to this address for problems or packages upgrades
// If empty or unset then no email is sent, make sure that you 
// have a working mail setup on your system. The package 'mailx'
// must be installed or anything that provides /usr/bin/mail.
//Unattended-Upgrade::Mail "root@localhost";

sends an email on every run. Instead, I would like to customize it to send only on error. Is there any way I can configure that?

2 Answers 2

9

Don't know why they deleted this line on Ubuntu, but Debian includes:

// Set this value to "true" to get emails only on errors. Default
// is to always send a mail if Unattended-Upgrade::Mail is set
//Unattended-Upgrade::MailOnlyOnError "true";

If your /etc/apt/apt.conf.d/50unattended-upgrades don't include the line (and the changelog don't give away this change in presice) is very odd, but at least it doesn't say they changed the behavior. I use a slightly updated version (0.80~sid2 opposed to 0.79.3ubuntu4 that Ubuntu includes in the precise-updates repository) and it will send a mail only on errors (I hasn't get a mail for now). Just write the lines to your configuration file, and everything should be working:

Unattended-Upgrade::Mail "[email protected]";
Unattended-Upgrade::MailOnlyOnError "true";

You may want to run sudo unattended-upgrade -v -d --dry-run to check the entire process yourself.

8
  • 1
    Ubuntu (at least some versions) seem to ignore this line: bugs.launchpad.net/ubuntu/+source/unattended-upgrades/+bug/…
    – dtech
    Jul 24, 2014 at 8:30
  • 1
    In 14.04 LTS, the line Unattended-Upgrade::MailOnlyOnError "true"; is back in /etc/apt/apt.conf.d/50unattended-upgrades. It's commented out by default.
    – azimut
    Oct 15, 2014 at 9:06
  • 1
    note that multiple addresses can be used as well with: Unattended-Upgrade::Mail "root,someuser,[email protected],[email protected]";
    – jimmont
    Oct 10, 2016 at 18:17
  • 1
    Newer versions of unattended-upgrade no longer email if --dry-run is specified
    – lily
    Oct 1, 2019 at 3:51
  • 1
    Indeed, how do we test this now?
    – Houman
    Nov 21, 2020 at 12:32
1

Works as of Linux Mint 20 which is pretty much Ubuntu 20.04.
To quote the comments in the file

Set this value to one of:
"always", "only-on-error" or "on-change"
If this is not set, then any legacy MailOnlyOnError (boolean) value
is used to chose between "only-on-error" and "on-change"

Unattended-Upgrade::MailReport "only-on-error";

You must log in to answer this question.

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