I am trying to understand how automatic upgrades are happening through the unattended-upgrades package. What is described below is what I found on a fresh install of Ubuntu 16.04.3.
/etc/cron.daily/apt-compat has a line
exec /usr/lib/apt/apt.systemd.daily at the end which executes the script
systemd also executes
/usr/lib/apt/apt.systemd.daily and it uses a timer. The systemd service definition doing the update can be found in
/lib/systemd/system/apt-daily.service. It calls the script
apt.systemd.daily with the argument
update while the systemd service definition in
/lib/systemd/system/apt-daily-upgrade.service calls the same script with the argument
As I understand,
/usr/lib/apt/apt.systemd.daily is the script used by unattended-upgrades package to do the automatic upgrades. What I would like to know is why do both cron and systemd execute it?