Wednesday, May 1, 2024
9
rated 0 times [  9] [ 0]  / answers: 1 / hits: 2450  / 2 Years ago, sat, may 7, 2022, 4:29:01

I have unattended-upgrades installed on several servers, some version 12, some 14. I would like to enable MailOnlyOnError for them but would still like to receive email notices when an update requires reboot.



Will I still receive "reboot required" notices with MailOnlyOnError enabled?



Thanks!


More From » notification

 Answers
1

Here is a solution based on an answer in this discussion.
The trick is that the request for a reboot is indicated by the presence of the file /var/run/reboot-required.



Create a file /usr/local/sbin/email_update_required with the content



if [ -f /var/run/reboot-required ]; then
echo "A reboot is required following updates to server `hostname`" | mail -s "Reboot Required" <mail-address>
fi


Adjust <mail-address> (for example to root or your personal email address). Check the permissions and make the file executable.



Put the following line into your root crontab (sudo crontab -e)



00 08 * * * /usr/local/sbin/email_update_required


(It runs the email_update_required script every day at 8 o’clock, adjust as needed.)



I've applied the above method to a Ubuntu 14.04 server with unattended-upgrades and MailOnlyOnError true", and it works.



Still, it would be nice to have a more "official" Ubuntu or unattended-upgrades way to get those notification mails. A switch similar to MailOnlyOnError would be great.


[#23192] Sunday, May 8, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mocipe

Total Points: 161
Total Questions: 106
Total Answers: 118

Location: Cambodia
Member since Thu, Oct 7, 2021
3 Years ago
;