如何自定义无人值守升级通知电子邮件?

May*_*yur 12 unattended-upgrades

有没有办法在ubuntu中自定义无人值守升级结果邮件?

/etc/apt/apt.conf.d/50unattended-upgrades文件中的当前配置-

// 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";
Run Code Online (Sandbox Code Playgroud)

每次运行都会发送一封电子邮件。相反,我想自定义它以仅在出错时发送。有什么办法可以配置吗?

Bra*_*iam 8

不知道为什么他们在 Ubuntu 上删除了这一行,但 Debian 包括:

// 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";
Run Code Online (Sandbox Code Playgroud)

如果您/etc/apt/apt.conf.d/50unattended-upgrades不包含该行(并且更改日志不会泄露此更改)是非常奇怪的,但至少它并没有说他们改变了行为。我使用了一个稍微更新的版本(0.80~sid2 与 Ubuntu 包含在精确更新存储库中的 0.79.3ubuntu4 相对),它只会在出现错误时发送邮件(我现在还没有收到邮件)。只需将这些行写入您的配置文件,一切都应该正常工作:

Unattended-Upgrade::Mail "your@email.com";
Unattended-Upgrade::MailOnlyOnError "true";
Run Code Online (Sandbox Code Playgroud)

您可能希望自己运行sudo unattended-upgrade -v -d --dry-run以检查整个过程。