Does anyone know if it is possible to determine the status of an unattended upgrade? Is it possible to find out which packages are being installed or where we are in the process?
I appreciate the benefit of unattended upgrades, but they can be really annoying when you have a system that's been off for a couple months, and you want to install an application or when they're eating CPU resources on machines that don't have much to begin with.
I'm not simply looking to kill the unattended upgrades. I know how to do that. I want them to run. I just want to know how I can find out what's actually going on and what phase they're in.
On a 16.04 and newer systems, unattended-upgrades runs daily at a random time.
How to tell when unattended upgrades will run today:
The random time is set by a cron job (/etc/cron.daily/apt.compat), and you can read the random time for today by asking systemd:
In this case, you can see that u-u ran 1 hour and 9 minutes ago.
How to tell if unattended upgrades are still running:
One easy way is to check the timestamp files for the various apt components:
You can see here that u-u is just another apt component. apt places the timestamp here regardless of how the apt was started.
Putting the data together, you can see that the timer started apt (u-u) at 11:22. It ran an update which completed at 11:23, then an upgrade which completed at 11:24. Finally, you can see that apt considered the upgrade to be a success (no error or other failure).
Obviously, if you see a recent timer without a corresponding completion timestamp, then you might want to check
ps
to see if apt is still running.How to tell which step apt is running right now:
One easy way is to check the u-u logfile.
Here you can see the normal daily process, including the 'started' and 'completed' lines, and the list of packages that were about to be upgraded.
If the list of packages is not logged yet, then apt can be safely interrupted. Once the list of packages is logged, DO NOT interrupt apt.
Since you have a resource-constrained environment, be aware that apt can be configured many ways to work reliably and unobtrusively with different run times, nice levels, bandwidth limits, and many other useful settings.
I use this to get total number of pending upgrades
To see if the upgrade is in progress:
To see what it's up to:
To see what packages are being upgraded:
Preview of the logs:
/var/log/unattended-upgrades/unattended-upgrades.log
- Note the timestamps and the length of time that elapsed before the list of packages was ready, this is on a system that I haven't used for months./var/log/unattended-upgrades/unattended-upgrades-dpkg.log