User avatar
ulysess
Posts: 310
Joined: Thu Aug 02, 2012 6:35 am
Location: Spain
Contact: Website

last time apt-get update was executed

Thu Sep 05, 2013 9:33 am

I'm making a script and I want to know last time the user executed apt-get update on the system

Any idea?

:?:
  • PiKISS for Raspberry Pi: https://github.com/jmcerrejon/PiKISS
  • Blog: https://misapuntesde.com/
  • Patreon: https://www.patreon.com/cerrejon?fan_landing=true
  • Twitter: https://twitter.com/ulysess10
  • Discord: https://discord.gg/Y7WFeC5

User avatar
rpdom
Posts: 17982
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: last time apt-get update was executed

Thu Sep 05, 2013 10:55 am

Have a look in /var/log/apt/history.log, it logs each time apt-get was run, with the command line used and packages were affected.

forenbenutzer
Posts: 148
Joined: Thu Aug 02, 2012 7:08 pm

Re: last time apt-get update was executed

Thu Sep 05, 2013 10:56 am

Maybe you could use something like

Code: Select all

watch "ps aux | grep apt-get"
every 10 seconds or so and scan the output for differences. Afterwards you could output the current date and time to a text file.

Edit: above solution might be better, of course.
Pitendo - Case And Emulator Project - http://edv-huber.com/index.php/problemloesungen/12-pitendo

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: last time apt-get update was executed

Thu Sep 05, 2013 4:38 pm

I'm surprised that there is no elegant, supported, way of accomplishing this?

If there is no alternative to poking around 'under the covers', then it was previously discussed here - http://serverfault.com/questions/20747/ ... th-apt-get

The final solution, of looking at date stamps on files in /var/cache/apt, is the one I was about to suggest before remembering to Google for it...
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

Return to “Raspberry Pi OS”