I need to find the last time that the

apt-get update

command was run on my server. How can I determine this information?

link|improve this question

33% accept rate
feedback

6 Answers

You could check the Access times on the files in /var/lib/apt/lists which is updated when you run apt-get update. If apt-get update was run with sudo you should have a line logged in /var/log/auth.log when it was done..

link|improve this answer
1  
As pointed out somewhere else, you may find some files aren't updated and therefore haven't been downloaded again. This is fine if you want to know how up to date your package lists are, but not if you want to know when apt-get update was last run. The former is more likely. – David Pashley Jun 6 '09 at 5:27
feedback

Synaptic logs a history file (>File > History) , aptitude logs both history in /var/log/aptitude and auto-installed packages in /var/lib/aptitude/pkgstates, so you could check these for latest activity.

Anapologetos

link|improve this answer
feedback

/var/log/dpkg.log will keep a history of what was done, but not necessarily which app called dpkg (synaptic, apt-get, etc).

link|improve this answer
feedback

I suspect you can check the last modified times on files /var/cache/apt to figure out when the last updates were applied to the package lists.

I just tested this, and ran "sudo apt-get update" twice in a row, and the dates did not change from their current value, but I suspect this is because there were no new updates to apply, and that the caches are up to date.

link|improve this answer
feedback

wrap apt-get in a script that first writes a timestamp to a file, and then does the usual work. that way, you can define the timestamp format and location ;)

link|improve this answer
Sujoy, Wrapping it in a script is not practical if you have hundreds of servers, and you do not wish to maintain yet another script that might cause problems the next time you update your apt-get package. I think the requestor is looking for an answer that makes use of information already existing in his computer. – pdwalker Jan 11 '11 at 14:44
feedback
$ ls -l /var/lib/dpkg/lock 
-rw-r----- 1 root root 0 2011-11-16 09:40 /var/lib/dpkg/lock
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.