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


12

有什么方法可以在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";

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

Answers:


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";

如果您/etc/apt/apt.conf.d/50unattended-upgrades不包括该行(并且更改日志也不会轻易放弃此更改),这很奇怪,但至少它没有说它们改变了行为。我使用的是稍有更新的版本(0.80〜sid2与Ubuntu在精确更新存储库中包含的0.79.3ubuntu4相对),它将仅在出现错误时发送邮件(我暂时未收到邮件)。只需将这些行写到您的配置文件中,一切就可以正常工作:

Unattended-Upgrade::Mail "your@email.com";
Unattended-Upgrade::MailOnlyOnError "true";

您可能需要sudo unattended-upgrade -v -d --dry-run自己检查整个过程。


1
Ubuntu(至少某些版本)似乎忽略了这一行:bugs.launchpad.net/ubuntu/+source/unattended-upgrades/+bug/…–
dtech

1
在14.04 LTS中,生产线Unattended-Upgrade::MailOnlyOnError "true";返回/etc/apt/apt.conf.d/50unattended-upgrades。默认情况下已注释掉。
azimut 2014年

请注意,也可以使用以下多个地址:Unattended-Upgrade::Mail "root,someuser,your@email.com,others@somewhere.com";
jimmont

如果新版本的无人值守升级不再电子邮件--dry-run指定的
钟淑慧
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.