Check the time stamp of /var/lib/apt/periodic/update-success-stamp.
$ ls -l /var/lib/apt/periodic/update-success-stamp
-rw-r--r-- 1 root root 0 Jan 25 01:41 /var/lib/apt/periodic/update-success-stamp
Here the time is Jan 25 01:41 when apt-get last executed. To get the time only, use the following command in terminal,
$ ls -l /var/lib/apt/periodic/update-success-stamp | awk '{print $6" "$7" "$8}'
Jan 25 01:41
It is the best place to check the last update time. If you found /var/lib/apt/periodic/ to be empty you can try,
ls -l /var/log/apt/history.log
Update
It is found that due to some reasons above files update-success-stamp or history.log remain unavailable in some systems. There is a new proposal from derobert to look into the file /var/cache/apt/pkgcache.bin.
pkgcache.bin is Apt's memory mapped package cache location. It get renewed after each update. So it is the perfect candidate to know the last time when apt was updated.
One can use the following command to know the exact time,
ls -l /var/cache/apt/pkgcache.bin | cut -d' ' -f6,7,8
or
stat /var/cache/apt/pkgcache.bin
/var/lib/apt/periodic/directory is empty – virtualxtc Jan 25 '14 at 08:08/var/cache/apt/pkgcache.bin. Also, please don't parse the output ofls; usestatinstead. Keep in mind thatlsoutput depends on locale, depends on age of file, etc. (Also, I think you only get the first file you suggest if you have update-notifier-common installed) – derobert Mar 12 '14 at 16:12/var/cache/apt/pkgcache.binis also touched on package installation, so it's not a reliable way to check for the lastapt-get updaterun. – GnP Dec 02 '16 at 20:18statwith-c %Yfor seconds since the epoch. – ssokolow Feb 22 '17 at 05:06apt-get cleanhas been run recently will have no/var/cache/apt/pkgcache.bin. I'm going to try using the mtime from/var/lib/apt/listsinstead, since that seems to be the raw, non-cached data whichapt-get updateactually manipulates. – ssokolow Feb 22 '17 at 10:12update-notifier-commonon 16.04 provided/etc/apt/apt.conf.d/15update-stampwhich contains the config to touch/var/lib/apt/periodic/update-success-stampafter successful update. Runningapt-get updateafter installing update-notifier-common does indeed create the update-success-stamp file. – mattpr Feb 26 '19 at 12:37