4

I've been tearing my hair out trying to figure out why running unattended-upgrade wouldn't result in an email in my inbox, only for one to turn up this morning.

Is there a way to help debugging a new config by forcing unattended-upgrade to send an email whenever it runs?

I don't get any lines about email at all in /var/log/unattended-upgrades/unattended-upgrades.log

I'm running Debian 10.

sandyscott
  • 235
  • 3
  • 9
  • 2
    Could you update your post to include the details from your `/etc/apt/apt.conf.d/50unattended-upgrades` file? Specifically the line referring to `Unattended-Upgrade::Mail`. Additionally what are you using to send the email? Is your smtp client/server setup properly? Thank you. – kemotep May 08 '20 at 12:17
  • To be clear: it is working, I recieved an email from the system when it did some updates this morning. The problem is I had no way to test if it was working while I had a fully patched system. That config line is `Unattended-Upgrade::Mail "[email protected]";`. I'm using exim4 and it's working fine - I can send emails from the shell as myself or root using `mail` or `mailx`. – sandyscott May 08 '20 at 17:07
  • I defined unattended-upgrade configuration in /etc/apt/apt.conf.d/50unattended-upgrades file. I receive an email with this subject: unattended-upgrades result for debian.example.com: SUCCESS. Where does that debian.example.com comes from? How could I add my VPS name instead? (I am using Exim4, and /etc/email-addresses is empty, is this related?) – user1185081 Jan 09 '22 at 14:57
  • @user1185081 You might have more luck posting that as a separate question. I haven't dug any deeper into this since I got it working. – sandyscott Jan 11 '22 at 12:48

1 Answers1

1

It will send an email if you uncomment this line and set it to "always". You dont have to use these sed commands, you can just edit the file. I'm just sharing them because I use several VMs:

sed -i 's,//Unattended-Upgrade::MailReport "on-change";,Unattended-Upgrade::MailReport "always";,' /etc/apt/apt.conf.d/50unattended-upgrades

Then set it only on error:

sed -i 's,Unattended-Upgrade::MailReport "always";,Unattended-Upgrade::MailReport "only-on-error";,' /etc/apt/apt.conf.d/50unattended-upgrades

Or to set it first to only on error:

sed -i 's,//Unattended-Upgrade::MailReport "on-change";,Unattended-Upgrade::MailReport "only-on-error";,' /etc/apt/apt.conf.d/50unattended-upgrades

Then run it manually with unattended-upgrades and it will send a "SUCCESS" email even if there are no updates to upgrade.

alchemy
  • 537
  • 5
  • 16