如何让无人值守升级每次运行时都给我发送电子邮件?

如何让无人值守升级每次运行时都给我发送电子邮件?

如何让无人值守升级在每次运行时向我发送电子邮件,即使没有需要更新的软件包?

当有升级时,他们会应用升级并通过电子邮件通知我,因此配置至少部分正确。

系统详细信息和配置

无人值守升级正在我的 Raspberry Pi 3b 上运行,它正在运行 stretch:

$ cat /etc/os-release | grep PRETTY
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)

我安装了unattended-upgrades,,,。ssmtpbsd-mailxapt-listchanges

删除我的电子邮件地址,未注释的内容50unattended-upgrades是:

Unattended-Upgrade::Origins-Pattern {
        "o=Raspbian, a=stable";
        "o=Raspberry Pi Foundation, a=stable";
};

Unattended-Upgrade::Package-Blacklist {
};

Unattended-Upgrade::MinimalSteps "true";
Unattended-Upgrade::Mail "[email protected]";
Unattended-Upgrade::MailOnlyOnError "false";
Unattended-Upgrade::Automatic-Reboot "true";

的内容20auto-upgrades为:

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::Unattended-Upgrade "1";
APT::Periodic::Verbose "1";
APT::Periodic::AutocleanInterval "7";

系统行为

6 月 10 日,无人值守升级运行,应用了一些升级并通过电子邮件发给我。

6 月 11 日,无人值守升级运行,没有升级或更新,我也没有收到电子邮件。查看 unattended-upgrades.log 后,我看到:

2019-06-10 06:13:06,708 INFO Initial blacklisted packages: 
2019-06-10 06:13:06,710 INFO Initial whitelisted packages: 
2019-06-10 06:13:06,711 INFO Starting unattended upgrades script
2019-06-10 06:13:06,712 INFO Allowed origins are: ['o=Raspbian, a=stable', 'o=Raspberry Pi Foundation, a=stable']
2019-06-10 06:14:48,222 INFO Packages that will be upgraded: ffmpeg libav-tools libavcodec57 libavdevice57 libavfilter6 libavformat57 libavresample3 libavutil55 libcupsfilters1 libpostproc54 libswresample2 libswscale4 omxplayer
2019-06-10 06:14:48,223 INFO Writing dpkg log to '/var/log/unattended-upgrades/unattended-upgrades-dpkg.log'
2019-06-10 06:24:41,720 INFO All upgrades installed
2019-06-10 06:24:55,243 INFO Packages that are auto removed: 'ffmpeg libav-tools libavdevice57 libsdl2-2.0-0'
2019-06-10 06:25:20,072 INFO Packages were successfully auto-removed
2019-06-11 06:45:06,671 INFO Initial blacklisted packages: 
2019-06-11 06:45:06,674 INFO Initial whitelisted packages: 
2019-06-11 06:45:06,675 INFO Starting unattended upgrades script
2019-06-11 06:45:06,676 INFO Allowed origins are: ['o=Raspbian, a=stable', 'o=Raspberry Pi Foundation, a=stable']
2019-06-11 06:45:24,801 INFO No packages found that can be upgraded unattended and no pending auto-removals

此外,查看我用于发送无人值守升级电子邮件的 Gmail 帐户,我发现 6 月 10 日发送了一封电子邮件,但没有发送 11 日的电子邮件。

此外,我刚刚跑了

"Test email" | mail -s "Test Mail" [email protected]

并在目的地地址收到了此邮件。

基于所有这些,我得出结论,除非有升级需要应用,否则无人值守升级不会给我发送邮件。但是我希望每天都能收到一封电子邮件,无论是否有升级。我该如何获得它?

(是的,我可以设置一个 cron 作业来通过电子邮件将日志文件的尾部发送给我,但我想通过无人值守升级来完成此操作,并且确认“我已经运行但不需要执行任何操作”似乎是它所支持的功能)

答案1

unattended-upgrades版本中2.8

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

相关内容