8

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!

  • Good question. I have a server with unnattended-upgrades and MailOnlyOnError and my impression is that unfortunately I don't get any info mails if a reboot is required. Would be nice to know if there is an "official" way to make this work. – azimut Oct 24 '14 at 10:39
7

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.

| improve this answer | |
  • Thanks! The discussion you linked to also points to this one which pointed me at using nagios to monitor /var/run/reboot. That'll work for us. – Whatsisname Oct 27 '14 at 15:47
  • Ah, wasn't aware of that other discussion. Thanks. – azimut Oct 27 '14 at 15:49
  • When posting this answer, I had applied the same to a server with unattended updates. In the last unatteded update, linux-image-3.13.0-39-generic was installed. And I got the first reboot-required message, so it works! – azimut Oct 29 '14 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.