Stop Ubuntu from running Auto Upgrades at boot – #DEVOPS

Hits: 3814

Devops need to automatically install stuff on Ubuntu, however this clashed with the daily ubuntu auto update.

The best way to stop autoupgrades is to prevent Ubuntu from download the updated package list

Edit /etc/apt/apt.conf.d/20periodic or whatever number it is

Change the 1 for Update-Package-Lists to a 0

APT::Periodic::Update-Package-Lists “0”;
APT::Periodic::Unattended-Upgrade “1”;

See:

https://askubuntu.com/questions/9/how-do-i-enable-automatic-updates

https://help.ubuntu.com/community/AutomaticSecurityUpdates

https://debian-handbook.info/browse/stable/sect.regular-upgrades.html

Other advice to kill the proccess that I did not follow:

The advice given at the link at the bottom is to kill the daily process, then run your devops. The Ubuntu daily will run later anyway.

 

#!/bin/bash

systemctl stop apt-daily.service
systemctl kill --kill-who=all apt-daily.service

# wait until `apt-get updated` has been killed
while ! (systemctl list-units --all apt-daily.service | fgrep -q dead)
do
  sleep 1;
done

# now proceed with own APT tasks
apt install -y python

I am running with docker-machine so leave out the install at the end if your using docker-machine.

I haven’t tried this yet, but plan to.

Source: systemd – How to disable `apt-daily.service` on Ubuntu cloud VM image? – Unix & Linux Stack Exchange