27

I just had a look at my Amazon EC2 instance and noticed I had 20 minutes exactly of downtime. I didn't know what caused it so I logged in to SSH and tried upgrading my packages, and saw that the unattended-upgrades package needed upgrading. I went ahead and did this.

After searching it seems like this package can automatically reboot your machine. Not sure why I didn't get to configure this as it came with the OS, but oh well.

Does anyone know how to prevent the package from automatically rebooting? Or how to stop it updating packages altogether? I can do that myself.

  • 2
    Be careful as I think that some security fixes (e.g. new kernel?) won't take effect until the next reboot. – AdamS Jul 18 '17 at 18:55

3 Answers3

40

Verify that in the configuration file: /etc/apt/apt.conf.d/50unattended-upgrades you have set:

Unattended-Upgrade::Automatic-Reboot "false";

This will prevent the software to issue reboot also if needed by the upgrades.

Documentation

ricciocri
  • 1,301
  • 1
    Is this directly active or is it required to reboot or export some variables, etc? – Radio Controlled Jan 24 '22 at 07:28
  • sudo sed -i 's/\/\/Unattended-Upgrade::Automatic-Reboot "false";/Unattended-Upgrade::Automatic-Reboot "false";/g' /etc/apt/apt.conf.d/50unattended-upgrades – Tyler Jan 22 '24 at 16:24
6

To disable automatic upgrades altogether, just remove the package. Try:

sudo apt-get remove unattended-upgrades

See Ubuntu docs for more info. However, if you want to keep the package and configure its behaviour, see this question's solution How do I enable automatic updates?

Paul Gear
  • 464
  • 1
    You first link's most voted answer suggest installing it and you're suggesting to remove it? Again, removing it beats the purpose of getting automatic unattendend upgrades altogether! – Anwar Aug 11 '16 at 09:53
  • @Anwar Okay, I intended to point to related info, but I agree that the first link could be confusing. Wrt. your second point, though the question includes Or how to stop it updating packages altogether? – Tijn Porcelijn Aug 11 '16 at 10:03
  • 1
    You may only extract that information out to point OP to the right direction? Since, it is confusing to see supporting link saying against (at first look at least) the answer. – Anwar Aug 11 '16 at 10:07
  • 1
    @AnwarShah Thanks for the suggestions! Hope it's clearer after last edits – Tijn Porcelijn Aug 11 '16 at 10:10
  • I believe you'd want to apt-get purge to kill unattended-upgrades in its entirety, not just apt-get remove. – Reid Jul 26 '18 at 20:03
  • 2
    Down vote, because removing unattended-upgrades is usually a bad idea. You will miss out on important security updates, especially considering this is a server instance, where you want these to be installed automatically. – Serrano Pereira Aug 23 '18 at 19:22
0

You can refer to this as well for disabling Amazon Linux's upgrade after reboot https://github.com/Nubisproject/nubis-base/issues/153