I want to know when we last ran the package upgrades/updates on our Debian server.
3 Answers
The file /var/log/apt/history.log
gives you information on when APT was run and what was done.
tail -3 /var/log/apt/history.log
will give you this information for the last run of APT (not necessarily the last run of upgrage, though).
To find out when was the last time you've run an upgrade, you want to look for a line starting with Upgrade:
and then lookup up the timestamp in the following line of the file (which starts with End-Date:
). The last such match is the last time you've run an upgrade.
![](../../users/profiles/33069.webp)
- 411
- 2
- 5
-
1Well, actually, it does show the commands that were run, including upgrades. However, if the event is a while back, you might have to look at the compressed log files, in which case tail won't work. You would have to unzip the files first. – wolfgangsz Jun 06 '11 at 16:23
-
@wolfgangsz You're right. By what I can see in my system, these files are rotated monthly. So, if your last upgrade was more than a month ago (or if you are in the beginning of a month) you might have to look in the previous files. – goedson Jun 06 '11 at 21:39
-
The immediate following line isn't always `End-Date:` - sometimes it is `Remove:`. So slightly more complicated to write a script. – Hamish Downer May 18 '12 at 13:15
-
1I've written a nagios plugin based on this idea - https://github.com/aptivate/check_apt_last_update – Hamish Downer Jun 05 '12 at 12:31
-
Thnx, ended up with `grep "apt upg" -n1 /var/log/apt/history.log | head -n1 | xargs | cut -f2-3 -d" "` --if they are in archived logs not history.log then it's old as frick so assume not run recently. – Tyeth Sep 08 '20 at 15:47
Outside of lucking out on log files located in /var/log/apt
- e.g.: /var/log/apt/var/log/history.log
or /var/log/term.log
The closest thing I can think about is to examine dpkg:
ls -alt /var/lib/dpkg/info | head -n 10
The dates on the top should approximate the last time apt handled those packages.
![](../../users/profiles/83522.webp)
- 4,676
- 20
- 38
-
-
1If you have an abundance of compressed history.x.gz logs you can traverse them using (I wouldn't suggest zcat'ting a large collection of active logs, but this should be fine for these ones) `zcat history.log.* |head -n 10` – thinice Jun 06 '11 at 17:56
There are some other comments that are not bad, but what you are really looking for is /var/log/dpkg.log
.
dpkg is a low level tool for manipulating packages thus every package modification will be logged there.
![](../../users/profiles/6491.webp)
- 6,607
- 24
- 42
-
3And, being low level, you can't know if the actions logged by it are the result of an `apt-get install xxx` or `apt-get upgrade` or even an `dpkg -i xxx.deb`. For finding out when you ran package upgrades, it's better to look into APT's logs. – goedson Jun 06 '11 at 21:35