How to know last time `apt-get update` was executed? The 2019 Stack Overflow Developer Survey Results Are InWhere can I look up my update history?Calling apt-get -y update in a bash script: once or multiple times?How to troubleshoot apt-get connection problems?Package information was last updated 59 days ago even though Ubuntu is up to dateProblems while doing 'sudo apt-get upgrade'Expanding APT-GET Repositoriessudo apt-get update returns an errorapt-get update: Err https://mirror.umd.edu -> server certificate verification failedError performing sudo apt update in persistent live boot system (ubuntu 16.04 LTS)apt-get update GPG errorGet a list of phased package upgrades for a script (apt vs. update-manager)Ubuntu 17.10 apt-get update giving 404 NOT FOUND error for repository

Why was M87 targeted for the Event Horizon Telescope instead of Sagittarius A*?

Why didn't the Event Horizon Telescope team mention Sagittarius A*?

How come people say “Would of”?

Worn-tile Scrabble

Why can't devices on different VLANs, but on the same subnet, communicate?

Kerning for subscripts of sigma?

Why isn't the circumferential light around the M87 black hole's event horizon symmetric?

Will it cause any balance problems to have PCs level up and gain the benefits of a long rest mid-fight?

Mathematics of imaging the black hole

The phrase "to the numbers born"?

What is this business jet?

Why not take a picture of a closer black hole?

Is it okay to consider publishing in my first year of PhD?

How can I define good in a religion that claims no moral authority?

Is it ok to offer lower paid work as a trial period before negotiating for a full-time job?

How do PCB vias affect signal quality?

Why don't hard Brexiteers insist on a hard border to prevent illegal immigration after Brexit?

For what reasons would an animal species NOT cross a *horizontal* land bridge?

How do I free up internal storage if I don't have any apps downloaded?

What do I do when my TA workload is more than expected?

What to do when moving next to a bird sanctuary with a loosely-domesticated cat?

Star Trek - X-shaped Item on Regula/Orbital Office Starbases

What is the light source in the black hole images?

Slides for 30 min~1 hr Skype tenure track application interview



How to know last time `apt-get update` was executed?



The 2019 Stack Overflow Developer Survey Results Are InWhere can I look up my update history?Calling apt-get -y update in a bash script: once or multiple times?How to troubleshoot apt-get connection problems?Package information was last updated 59 days ago even though Ubuntu is up to dateProblems while doing 'sudo apt-get upgrade'Expanding APT-GET Repositoriessudo apt-get update returns an errorapt-get update: Err https://mirror.umd.edu -> server certificate verification failedError performing sudo apt update in persistent live boot system (ubuntu 16.04 LTS)apt-get update GPG errorGet a list of phased package upgrades for a script (apt vs. update-manager)Ubuntu 17.10 apt-get update giving 404 NOT FOUND error for repository



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








23















I know that the command to update the repository lists is apt-get update.



How to check if it has been executed today or in the last 24 hours?



I do not known if should check some file timestamp. Or issue another apt command. Or use dpkg utility.



Could not find something useful at man pages.










share|improve this question






























    23















    I know that the command to update the repository lists is apt-get update.



    How to check if it has been executed today or in the last 24 hours?



    I do not known if should check some file timestamp. Or issue another apt command. Or use dpkg utility.



    Could not find something useful at man pages.










    share|improve this question


























      23












      23








      23


      15






      I know that the command to update the repository lists is apt-get update.



      How to check if it has been executed today or in the last 24 hours?



      I do not known if should check some file timestamp. Or issue another apt command. Or use dpkg utility.



      Could not find something useful at man pages.










      share|improve this question
















      I know that the command to update the repository lists is apt-get update.



      How to check if it has been executed today or in the last 24 hours?



      I do not known if should check some file timestamp. Or issue another apt command. Or use dpkg utility.



      Could not find something useful at man pages.







      apt updates logs






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 1 '16 at 20:06









      200_success

      859816




      859816










      asked Jan 24 '14 at 19:27









      cavilacavila

      238126




      238126




















          8 Answers
          8






          active

          oldest

          votes


















          14














          You can check your command history in terminal :



          history | grep 'apt update'


          To check it by time :



          HISTTIMEFORMAT="%d/%m/%y %T " history | grep '[a]pt update'


          (The [a] part of the regular expression only matches the letter a but has the effect to not match itself when grepping in the history.)



          enter image description here



          Hope it helps !






          share|improve this answer




















          • 2





            It is history | grep 'apt-get update' :)

            – Lucio
            Jan 24 '14 at 19:47






          • 7





            @souravc is right. This won't work on its own. If the HISTTIMEFORMAT is not set in .bashrc then this command will only have correct timestamps for the commands which were actually executed from the current shell session. For all the other commands which is not from the current session the timestamp will only show the modification timestamp of the ~/.bash_history file. It can't show the timestamps for commands from other sessions as those timestamps are not saved in the ~/.bash_history file. It can show timestamps for the current session because those stamps are still in the memory.

            – falconer
            Jan 25 '14 at 12:25






          • 7





            This does not always work. E.g. when some other user ran apt or when your .bash_history has been trimmed.

            – OrangeTux
            Jan 26 '14 at 20:11







          • 4





            This is a terribly wrong answer. It doesn't account for unattended upgrades, plus if you're someone like me who always has 4-5 terminals open, the history only gets saved when they exit (by default), so you would have to check all of them.

            – hackel
            May 16 '17 at 17:26






          • 3





            Echoing what everyone has already said, that won't work if apt has been updated by a script, if you're not looking at the right history, if the history has been trimmed, or if another user has done the update. That's really not reliable enough to solve the general case.

            – zneak
            Sep 25 '17 at 18:35


















          49














          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





          share|improve this answer

























          • my /var/lib/apt/periodic/ directory is empty

            – virtualxtc
            Jan 25 '14 at 8:08











          • My directory is also empty. Debian 7.3 wheezy.

            – cavila
            Jan 25 '14 at 11:53






          • 5





            A better backup location would be /var/cache/apt/pkgcache.bin. Also, please don't parse the output of ls; use stat instead. Keep in mind that ls output 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







          • 1





            It seems /var/cache/apt/pkgcache.bin is also touched on package installation, so it's not a reliable way to check for the last apt-get update run.

            – GnP
            Dec 2 '16 at 20:18






          • 3





            ...and I just discovered that a Debian 8 system where apt-get clean has been run recently will have no /var/cache/apt/pkgcache.bin. I'm going to try using the mtime from /var/lib/apt/lists instead, since that seems to be the raw, non-cached data which apt-get update actually manipulates.

            – ssokolow
            Feb 22 '17 at 10:12


















          6














          I use /var/cache/apt to determine if I need to run apt-get update. By default, if the difference between the current time and cache time of /var/cache/apt is less than 24 hr, I don't need to run apt-get update. The default update interval can be overridden by passing a number to function runAptGetUpdate()



          function trimString()

          local -r string="$1"

          sed -e 's/^ *//g' -e 's/ *$//g' <<< "$string"


          function isEmptyString()

          local -r string="$1"

          if [[ "$(trimString "$string")" = '' ]]
          then
          echo 'true'
          else
          echo 'false'
          fi


          function info()

          local -r message="$1"

          echo -e "33[1;36m$message33[0m" 2>&1


          function getLastAptGetUpdate()

          local aptDate="$(stat -c %Y '/var/cache/apt')"
          local nowDate="$(date +'%s')"

          echo $((nowDate - aptDate))


          function runAptGetUpdate()

          local updateInterval="$1"

          local lastAptGetUpdate="$(getLastAptGetUpdate)"

          if [[ "$(isEmptyString "$updateInterval")" = 'true' ]]
          then
          # Default To 24 hours
          updateInterval="$((24 * 60 * 60))"
          fi

          if [[ "$lastAptGetUpdate" -gt "$updateInterval" ]]
          then
          info "apt-get update"
          apt-get update -m
          else
          local lastUpdate="$(date -u -d @"$lastAptGetUpdate" +'%-Hh %-Mm %-Ss')"

          info "nSkip apt-get update because its last run was '$lastUpdate' ago"
          fi



          Sample Output:



          <root@ubuntu><~/ubuntu-cookbooks/libraries>
          # runAptGetUpdate

          Skip apt-get update because its last run was '0h 37m 43s' ago


          I extracted these functions from my personal github: https://github.com/gdbtek/ubuntu-cookbooks/blob/master/libraries/util.bash






          share|improve this answer
































            2














            You may also interested about the file:



            /var/log/apt/term.log


            Open it with less or cat as root.






            share|improve this answer























            • This is a sensible place to check for logs of actions apt has performed on the package database, but afaik the poster wants to know about apt-get update, and that is obviously not logged.

              – Faheem Mitha
              Mar 12 '14 at 16:00


















            1














            I use this command



            stat /var/cache/apt/ | grep -i -e access -e modify



            to show last time it was accessed ie. running 'apt-get update' also last time it was actually updated.



            note if the times are different there may not have been an update available. Since I have my updates and upgrades running by crontab at specific times I can tell if my updates ran or not.






            share|improve this answer






























              1














              Combining @ssokolow's last comment with the answer from here, this command will run apt-get update if it hasn't run in the last 7 days:



              [ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mtime -7)" ] && sudo apt-get update


              Explanation:




              • -mtime -7 finds files that have a change time in the last 7 days. You can use -mmin if you care about shorter times.


              • -maxdepth 0 ensures find won't go into the contents of the directory.


              • -H dereferences /var/lib/apt/lists if it's a soft link

              • If for some reason find fails, then the command would run. This seems to me like the safe default. If you want to flip the default, use -n in the test and -mtime +7 in the find command.





              share|improve this answer
































                0














                I just posted an answer to this question on following topic



                Where can I look up my update history?



                The answer may be less appropriate for this topic, as it specifically looks for "apt-get upgrade". Here's sample output.



                xenial% 9: ./linuxpatchdate 
                2016-07-19 54
                2017-02-24 363
                2017-03-08 7
                2017-03-09 2


                See the other topic for source code and more explanation.






                share|improve this answer

























                • It looked to me like your code looked for upgrade, not update. For example, I just ran "apt-get update" (the subject of this question) on my Ubuntu 16.04 and not one iota of change appears in /var/log/apt, implying that scanning anything in that directory will be of no use in answer this particular question.

                  – Ron Burk
                  May 1 '17 at 20:56






                • 1





                  You're totally right. Thanks for pointing that out. I've changed my answer to reflect that. We were looking for the last date updates were applied to the machine, rather than updates being just downloaded.

                  – JsinJ
                  May 4 '17 at 4:40


















                0














                LAST_UPDATED=$( stat --format="%X" /var/cache/apt/pkgcache.bin )
                UNIX_TIME=$( date +%s )
                TIME_DIFF=$(( UNIX_TIME - LAST_UPDATED ))

                if [[ "$TIME_DIFF" -gt 43200 ]]
                then
                # It's been 12 hours since apt-get update was ran.
                fi





                share|improve this answer























                  Your Answer








                  StackExchange.ready(function()
                  var channelOptions =
                  tags: "".split(" "),
                  id: "89"
                  ;
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function()
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled)
                  StackExchange.using("snippets", function()
                  createEditor();
                  );

                  else
                  createEditor();

                  );

                  function createEditor()
                  StackExchange.prepareEditor(
                  heartbeatType: 'answer',
                  autoActivateHeartbeat: false,
                  convertImagesToLinks: true,
                  noModals: true,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: 10,
                  bindNavPrevention: true,
                  postfix: "",
                  imageUploader:
                  brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                  contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                  allowUrls: true
                  ,
                  onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  );



                  );













                  draft saved

                  draft discarded


















                  StackExchange.ready(
                  function ()
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f410247%2fhow-to-know-last-time-apt-get-update-was-executed%23new-answer', 'question_page');

                  );

                  Post as a guest















                  Required, but never shown

























                  8 Answers
                  8






                  active

                  oldest

                  votes








                  8 Answers
                  8






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  14














                  You can check your command history in terminal :



                  history | grep 'apt update'


                  To check it by time :



                  HISTTIMEFORMAT="%d/%m/%y %T " history | grep '[a]pt update'


                  (The [a] part of the regular expression only matches the letter a but has the effect to not match itself when grepping in the history.)



                  enter image description here



                  Hope it helps !






                  share|improve this answer




















                  • 2





                    It is history | grep 'apt-get update' :)

                    – Lucio
                    Jan 24 '14 at 19:47






                  • 7





                    @souravc is right. This won't work on its own. If the HISTTIMEFORMAT is not set in .bashrc then this command will only have correct timestamps for the commands which were actually executed from the current shell session. For all the other commands which is not from the current session the timestamp will only show the modification timestamp of the ~/.bash_history file. It can't show the timestamps for commands from other sessions as those timestamps are not saved in the ~/.bash_history file. It can show timestamps for the current session because those stamps are still in the memory.

                    – falconer
                    Jan 25 '14 at 12:25






                  • 7





                    This does not always work. E.g. when some other user ran apt or when your .bash_history has been trimmed.

                    – OrangeTux
                    Jan 26 '14 at 20:11







                  • 4





                    This is a terribly wrong answer. It doesn't account for unattended upgrades, plus if you're someone like me who always has 4-5 terminals open, the history only gets saved when they exit (by default), so you would have to check all of them.

                    – hackel
                    May 16 '17 at 17:26






                  • 3





                    Echoing what everyone has already said, that won't work if apt has been updated by a script, if you're not looking at the right history, if the history has been trimmed, or if another user has done the update. That's really not reliable enough to solve the general case.

                    – zneak
                    Sep 25 '17 at 18:35















                  14














                  You can check your command history in terminal :



                  history | grep 'apt update'


                  To check it by time :



                  HISTTIMEFORMAT="%d/%m/%y %T " history | grep '[a]pt update'


                  (The [a] part of the regular expression only matches the letter a but has the effect to not match itself when grepping in the history.)



                  enter image description here



                  Hope it helps !






                  share|improve this answer




















                  • 2





                    It is history | grep 'apt-get update' :)

                    – Lucio
                    Jan 24 '14 at 19:47






                  • 7





                    @souravc is right. This won't work on its own. If the HISTTIMEFORMAT is not set in .bashrc then this command will only have correct timestamps for the commands which were actually executed from the current shell session. For all the other commands which is not from the current session the timestamp will only show the modification timestamp of the ~/.bash_history file. It can't show the timestamps for commands from other sessions as those timestamps are not saved in the ~/.bash_history file. It can show timestamps for the current session because those stamps are still in the memory.

                    – falconer
                    Jan 25 '14 at 12:25






                  • 7





                    This does not always work. E.g. when some other user ran apt or when your .bash_history has been trimmed.

                    – OrangeTux
                    Jan 26 '14 at 20:11







                  • 4





                    This is a terribly wrong answer. It doesn't account for unattended upgrades, plus if you're someone like me who always has 4-5 terminals open, the history only gets saved when they exit (by default), so you would have to check all of them.

                    – hackel
                    May 16 '17 at 17:26






                  • 3





                    Echoing what everyone has already said, that won't work if apt has been updated by a script, if you're not looking at the right history, if the history has been trimmed, or if another user has done the update. That's really not reliable enough to solve the general case.

                    – zneak
                    Sep 25 '17 at 18:35













                  14












                  14








                  14







                  You can check your command history in terminal :



                  history | grep 'apt update'


                  To check it by time :



                  HISTTIMEFORMAT="%d/%m/%y %T " history | grep '[a]pt update'


                  (The [a] part of the regular expression only matches the letter a but has the effect to not match itself when grepping in the history.)



                  enter image description here



                  Hope it helps !






                  share|improve this answer















                  You can check your command history in terminal :



                  history | grep 'apt update'


                  To check it by time :



                  HISTTIMEFORMAT="%d/%m/%y %T " history | grep '[a]pt update'


                  (The [a] part of the regular expression only matches the letter a but has the effect to not match itself when grepping in the history.)



                  enter image description here



                  Hope it helps !







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 2 days ago


























                  community wiki





                  15 revs, 3 users 78%
                  nux








                  • 2





                    It is history | grep 'apt-get update' :)

                    – Lucio
                    Jan 24 '14 at 19:47






                  • 7





                    @souravc is right. This won't work on its own. If the HISTTIMEFORMAT is not set in .bashrc then this command will only have correct timestamps for the commands which were actually executed from the current shell session. For all the other commands which is not from the current session the timestamp will only show the modification timestamp of the ~/.bash_history file. It can't show the timestamps for commands from other sessions as those timestamps are not saved in the ~/.bash_history file. It can show timestamps for the current session because those stamps are still in the memory.

                    – falconer
                    Jan 25 '14 at 12:25






                  • 7





                    This does not always work. E.g. when some other user ran apt or when your .bash_history has been trimmed.

                    – OrangeTux
                    Jan 26 '14 at 20:11







                  • 4





                    This is a terribly wrong answer. It doesn't account for unattended upgrades, plus if you're someone like me who always has 4-5 terminals open, the history only gets saved when they exit (by default), so you would have to check all of them.

                    – hackel
                    May 16 '17 at 17:26






                  • 3





                    Echoing what everyone has already said, that won't work if apt has been updated by a script, if you're not looking at the right history, if the history has been trimmed, or if another user has done the update. That's really not reliable enough to solve the general case.

                    – zneak
                    Sep 25 '17 at 18:35












                  • 2





                    It is history | grep 'apt-get update' :)

                    – Lucio
                    Jan 24 '14 at 19:47






                  • 7





                    @souravc is right. This won't work on its own. If the HISTTIMEFORMAT is not set in .bashrc then this command will only have correct timestamps for the commands which were actually executed from the current shell session. For all the other commands which is not from the current session the timestamp will only show the modification timestamp of the ~/.bash_history file. It can't show the timestamps for commands from other sessions as those timestamps are not saved in the ~/.bash_history file. It can show timestamps for the current session because those stamps are still in the memory.

                    – falconer
                    Jan 25 '14 at 12:25






                  • 7





                    This does not always work. E.g. when some other user ran apt or when your .bash_history has been trimmed.

                    – OrangeTux
                    Jan 26 '14 at 20:11







                  • 4





                    This is a terribly wrong answer. It doesn't account for unattended upgrades, plus if you're someone like me who always has 4-5 terminals open, the history only gets saved when they exit (by default), so you would have to check all of them.

                    – hackel
                    May 16 '17 at 17:26






                  • 3





                    Echoing what everyone has already said, that won't work if apt has been updated by a script, if you're not looking at the right history, if the history has been trimmed, or if another user has done the update. That's really not reliable enough to solve the general case.

                    – zneak
                    Sep 25 '17 at 18:35







                  2




                  2





                  It is history | grep 'apt-get update' :)

                  – Lucio
                  Jan 24 '14 at 19:47





                  It is history | grep 'apt-get update' :)

                  – Lucio
                  Jan 24 '14 at 19:47




                  7




                  7





                  @souravc is right. This won't work on its own. If the HISTTIMEFORMAT is not set in .bashrc then this command will only have correct timestamps for the commands which were actually executed from the current shell session. For all the other commands which is not from the current session the timestamp will only show the modification timestamp of the ~/.bash_history file. It can't show the timestamps for commands from other sessions as those timestamps are not saved in the ~/.bash_history file. It can show timestamps for the current session because those stamps are still in the memory.

                  – falconer
                  Jan 25 '14 at 12:25





                  @souravc is right. This won't work on its own. If the HISTTIMEFORMAT is not set in .bashrc then this command will only have correct timestamps for the commands which were actually executed from the current shell session. For all the other commands which is not from the current session the timestamp will only show the modification timestamp of the ~/.bash_history file. It can't show the timestamps for commands from other sessions as those timestamps are not saved in the ~/.bash_history file. It can show timestamps for the current session because those stamps are still in the memory.

                  – falconer
                  Jan 25 '14 at 12:25




                  7




                  7





                  This does not always work. E.g. when some other user ran apt or when your .bash_history has been trimmed.

                  – OrangeTux
                  Jan 26 '14 at 20:11






                  This does not always work. E.g. when some other user ran apt or when your .bash_history has been trimmed.

                  – OrangeTux
                  Jan 26 '14 at 20:11





                  4




                  4





                  This is a terribly wrong answer. It doesn't account for unattended upgrades, plus if you're someone like me who always has 4-5 terminals open, the history only gets saved when they exit (by default), so you would have to check all of them.

                  – hackel
                  May 16 '17 at 17:26





                  This is a terribly wrong answer. It doesn't account for unattended upgrades, plus if you're someone like me who always has 4-5 terminals open, the history only gets saved when they exit (by default), so you would have to check all of them.

                  – hackel
                  May 16 '17 at 17:26




                  3




                  3





                  Echoing what everyone has already said, that won't work if apt has been updated by a script, if you're not looking at the right history, if the history has been trimmed, or if another user has done the update. That's really not reliable enough to solve the general case.

                  – zneak
                  Sep 25 '17 at 18:35





                  Echoing what everyone has already said, that won't work if apt has been updated by a script, if you're not looking at the right history, if the history has been trimmed, or if another user has done the update. That's really not reliable enough to solve the general case.

                  – zneak
                  Sep 25 '17 at 18:35













                  49














                  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





                  share|improve this answer

























                  • my /var/lib/apt/periodic/ directory is empty

                    – virtualxtc
                    Jan 25 '14 at 8:08











                  • My directory is also empty. Debian 7.3 wheezy.

                    – cavila
                    Jan 25 '14 at 11:53






                  • 5





                    A better backup location would be /var/cache/apt/pkgcache.bin. Also, please don't parse the output of ls; use stat instead. Keep in mind that ls output 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







                  • 1





                    It seems /var/cache/apt/pkgcache.bin is also touched on package installation, so it's not a reliable way to check for the last apt-get update run.

                    – GnP
                    Dec 2 '16 at 20:18






                  • 3





                    ...and I just discovered that a Debian 8 system where apt-get clean has been run recently will have no /var/cache/apt/pkgcache.bin. I'm going to try using the mtime from /var/lib/apt/lists instead, since that seems to be the raw, non-cached data which apt-get update actually manipulates.

                    – ssokolow
                    Feb 22 '17 at 10:12















                  49














                  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





                  share|improve this answer

























                  • my /var/lib/apt/periodic/ directory is empty

                    – virtualxtc
                    Jan 25 '14 at 8:08











                  • My directory is also empty. Debian 7.3 wheezy.

                    – cavila
                    Jan 25 '14 at 11:53






                  • 5





                    A better backup location would be /var/cache/apt/pkgcache.bin. Also, please don't parse the output of ls; use stat instead. Keep in mind that ls output 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







                  • 1





                    It seems /var/cache/apt/pkgcache.bin is also touched on package installation, so it's not a reliable way to check for the last apt-get update run.

                    – GnP
                    Dec 2 '16 at 20:18






                  • 3





                    ...and I just discovered that a Debian 8 system where apt-get clean has been run recently will have no /var/cache/apt/pkgcache.bin. I'm going to try using the mtime from /var/lib/apt/lists instead, since that seems to be the raw, non-cached data which apt-get update actually manipulates.

                    – ssokolow
                    Feb 22 '17 at 10:12













                  49












                  49








                  49







                  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





                  share|improve this answer















                  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






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Apr 13 '17 at 12:25









                  Community

                  1




                  1










                  answered Jan 24 '14 at 19:45









                  souravcsouravc

                  27.8k1378108




                  27.8k1378108












                  • my /var/lib/apt/periodic/ directory is empty

                    – virtualxtc
                    Jan 25 '14 at 8:08











                  • My directory is also empty. Debian 7.3 wheezy.

                    – cavila
                    Jan 25 '14 at 11:53






                  • 5





                    A better backup location would be /var/cache/apt/pkgcache.bin. Also, please don't parse the output of ls; use stat instead. Keep in mind that ls output 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







                  • 1





                    It seems /var/cache/apt/pkgcache.bin is also touched on package installation, so it's not a reliable way to check for the last apt-get update run.

                    – GnP
                    Dec 2 '16 at 20:18






                  • 3





                    ...and I just discovered that a Debian 8 system where apt-get clean has been run recently will have no /var/cache/apt/pkgcache.bin. I'm going to try using the mtime from /var/lib/apt/lists instead, since that seems to be the raw, non-cached data which apt-get update actually manipulates.

                    – ssokolow
                    Feb 22 '17 at 10:12

















                  • my /var/lib/apt/periodic/ directory is empty

                    – virtualxtc
                    Jan 25 '14 at 8:08











                  • My directory is also empty. Debian 7.3 wheezy.

                    – cavila
                    Jan 25 '14 at 11:53






                  • 5





                    A better backup location would be /var/cache/apt/pkgcache.bin. Also, please don't parse the output of ls; use stat instead. Keep in mind that ls output 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







                  • 1





                    It seems /var/cache/apt/pkgcache.bin is also touched on package installation, so it's not a reliable way to check for the last apt-get update run.

                    – GnP
                    Dec 2 '16 at 20:18






                  • 3





                    ...and I just discovered that a Debian 8 system where apt-get clean has been run recently will have no /var/cache/apt/pkgcache.bin. I'm going to try using the mtime from /var/lib/apt/lists instead, since that seems to be the raw, non-cached data which apt-get update actually manipulates.

                    – ssokolow
                    Feb 22 '17 at 10:12
















                  my /var/lib/apt/periodic/ directory is empty

                  – virtualxtc
                  Jan 25 '14 at 8:08





                  my /var/lib/apt/periodic/ directory is empty

                  – virtualxtc
                  Jan 25 '14 at 8:08













                  My directory is also empty. Debian 7.3 wheezy.

                  – cavila
                  Jan 25 '14 at 11:53





                  My directory is also empty. Debian 7.3 wheezy.

                  – cavila
                  Jan 25 '14 at 11:53




                  5




                  5





                  A better backup location would be /var/cache/apt/pkgcache.bin. Also, please don't parse the output of ls; use stat instead. Keep in mind that ls output 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






                  A better backup location would be /var/cache/apt/pkgcache.bin. Also, please don't parse the output of ls; use stat instead. Keep in mind that ls output 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





                  1




                  1





                  It seems /var/cache/apt/pkgcache.bin is also touched on package installation, so it's not a reliable way to check for the last apt-get update run.

                  – GnP
                  Dec 2 '16 at 20:18





                  It seems /var/cache/apt/pkgcache.bin is also touched on package installation, so it's not a reliable way to check for the last apt-get update run.

                  – GnP
                  Dec 2 '16 at 20:18




                  3




                  3





                  ...and I just discovered that a Debian 8 system where apt-get clean has been run recently will have no /var/cache/apt/pkgcache.bin. I'm going to try using the mtime from /var/lib/apt/lists instead, since that seems to be the raw, non-cached data which apt-get update actually manipulates.

                  – ssokolow
                  Feb 22 '17 at 10:12





                  ...and I just discovered that a Debian 8 system where apt-get clean has been run recently will have no /var/cache/apt/pkgcache.bin. I'm going to try using the mtime from /var/lib/apt/lists instead, since that seems to be the raw, non-cached data which apt-get update actually manipulates.

                  – ssokolow
                  Feb 22 '17 at 10:12











                  6














                  I use /var/cache/apt to determine if I need to run apt-get update. By default, if the difference between the current time and cache time of /var/cache/apt is less than 24 hr, I don't need to run apt-get update. The default update interval can be overridden by passing a number to function runAptGetUpdate()



                  function trimString()

                  local -r string="$1"

                  sed -e 's/^ *//g' -e 's/ *$//g' <<< "$string"


                  function isEmptyString()

                  local -r string="$1"

                  if [[ "$(trimString "$string")" = '' ]]
                  then
                  echo 'true'
                  else
                  echo 'false'
                  fi


                  function info()

                  local -r message="$1"

                  echo -e "33[1;36m$message33[0m" 2>&1


                  function getLastAptGetUpdate()

                  local aptDate="$(stat -c %Y '/var/cache/apt')"
                  local nowDate="$(date +'%s')"

                  echo $((nowDate - aptDate))


                  function runAptGetUpdate()

                  local updateInterval="$1"

                  local lastAptGetUpdate="$(getLastAptGetUpdate)"

                  if [[ "$(isEmptyString "$updateInterval")" = 'true' ]]
                  then
                  # Default To 24 hours
                  updateInterval="$((24 * 60 * 60))"
                  fi

                  if [[ "$lastAptGetUpdate" -gt "$updateInterval" ]]
                  then
                  info "apt-get update"
                  apt-get update -m
                  else
                  local lastUpdate="$(date -u -d @"$lastAptGetUpdate" +'%-Hh %-Mm %-Ss')"

                  info "nSkip apt-get update because its last run was '$lastUpdate' ago"
                  fi



                  Sample Output:



                  <root@ubuntu><~/ubuntu-cookbooks/libraries>
                  # runAptGetUpdate

                  Skip apt-get update because its last run was '0h 37m 43s' ago


                  I extracted these functions from my personal github: https://github.com/gdbtek/ubuntu-cookbooks/blob/master/libraries/util.bash






                  share|improve this answer





























                    6














                    I use /var/cache/apt to determine if I need to run apt-get update. By default, if the difference between the current time and cache time of /var/cache/apt is less than 24 hr, I don't need to run apt-get update. The default update interval can be overridden by passing a number to function runAptGetUpdate()



                    function trimString()

                    local -r string="$1"

                    sed -e 's/^ *//g' -e 's/ *$//g' <<< "$string"


                    function isEmptyString()

                    local -r string="$1"

                    if [[ "$(trimString "$string")" = '' ]]
                    then
                    echo 'true'
                    else
                    echo 'false'
                    fi


                    function info()

                    local -r message="$1"

                    echo -e "33[1;36m$message33[0m" 2>&1


                    function getLastAptGetUpdate()

                    local aptDate="$(stat -c %Y '/var/cache/apt')"
                    local nowDate="$(date +'%s')"

                    echo $((nowDate - aptDate))


                    function runAptGetUpdate()

                    local updateInterval="$1"

                    local lastAptGetUpdate="$(getLastAptGetUpdate)"

                    if [[ "$(isEmptyString "$updateInterval")" = 'true' ]]
                    then
                    # Default To 24 hours
                    updateInterval="$((24 * 60 * 60))"
                    fi

                    if [[ "$lastAptGetUpdate" -gt "$updateInterval" ]]
                    then
                    info "apt-get update"
                    apt-get update -m
                    else
                    local lastUpdate="$(date -u -d @"$lastAptGetUpdate" +'%-Hh %-Mm %-Ss')"

                    info "nSkip apt-get update because its last run was '$lastUpdate' ago"
                    fi



                    Sample Output:



                    <root@ubuntu><~/ubuntu-cookbooks/libraries>
                    # runAptGetUpdate

                    Skip apt-get update because its last run was '0h 37m 43s' ago


                    I extracted these functions from my personal github: https://github.com/gdbtek/ubuntu-cookbooks/blob/master/libraries/util.bash






                    share|improve this answer



























                      6












                      6








                      6







                      I use /var/cache/apt to determine if I need to run apt-get update. By default, if the difference between the current time and cache time of /var/cache/apt is less than 24 hr, I don't need to run apt-get update. The default update interval can be overridden by passing a number to function runAptGetUpdate()



                      function trimString()

                      local -r string="$1"

                      sed -e 's/^ *//g' -e 's/ *$//g' <<< "$string"


                      function isEmptyString()

                      local -r string="$1"

                      if [[ "$(trimString "$string")" = '' ]]
                      then
                      echo 'true'
                      else
                      echo 'false'
                      fi


                      function info()

                      local -r message="$1"

                      echo -e "33[1;36m$message33[0m" 2>&1


                      function getLastAptGetUpdate()

                      local aptDate="$(stat -c %Y '/var/cache/apt')"
                      local nowDate="$(date +'%s')"

                      echo $((nowDate - aptDate))


                      function runAptGetUpdate()

                      local updateInterval="$1"

                      local lastAptGetUpdate="$(getLastAptGetUpdate)"

                      if [[ "$(isEmptyString "$updateInterval")" = 'true' ]]
                      then
                      # Default To 24 hours
                      updateInterval="$((24 * 60 * 60))"
                      fi

                      if [[ "$lastAptGetUpdate" -gt "$updateInterval" ]]
                      then
                      info "apt-get update"
                      apt-get update -m
                      else
                      local lastUpdate="$(date -u -d @"$lastAptGetUpdate" +'%-Hh %-Mm %-Ss')"

                      info "nSkip apt-get update because its last run was '$lastUpdate' ago"
                      fi



                      Sample Output:



                      <root@ubuntu><~/ubuntu-cookbooks/libraries>
                      # runAptGetUpdate

                      Skip apt-get update because its last run was '0h 37m 43s' ago


                      I extracted these functions from my personal github: https://github.com/gdbtek/ubuntu-cookbooks/blob/master/libraries/util.bash






                      share|improve this answer















                      I use /var/cache/apt to determine if I need to run apt-get update. By default, if the difference between the current time and cache time of /var/cache/apt is less than 24 hr, I don't need to run apt-get update. The default update interval can be overridden by passing a number to function runAptGetUpdate()



                      function trimString()

                      local -r string="$1"

                      sed -e 's/^ *//g' -e 's/ *$//g' <<< "$string"


                      function isEmptyString()

                      local -r string="$1"

                      if [[ "$(trimString "$string")" = '' ]]
                      then
                      echo 'true'
                      else
                      echo 'false'
                      fi


                      function info()

                      local -r message="$1"

                      echo -e "33[1;36m$message33[0m" 2>&1


                      function getLastAptGetUpdate()

                      local aptDate="$(stat -c %Y '/var/cache/apt')"
                      local nowDate="$(date +'%s')"

                      echo $((nowDate - aptDate))


                      function runAptGetUpdate()

                      local updateInterval="$1"

                      local lastAptGetUpdate="$(getLastAptGetUpdate)"

                      if [[ "$(isEmptyString "$updateInterval")" = 'true' ]]
                      then
                      # Default To 24 hours
                      updateInterval="$((24 * 60 * 60))"
                      fi

                      if [[ "$lastAptGetUpdate" -gt "$updateInterval" ]]
                      then
                      info "apt-get update"
                      apt-get update -m
                      else
                      local lastUpdate="$(date -u -d @"$lastAptGetUpdate" +'%-Hh %-Mm %-Ss')"

                      info "nSkip apt-get update because its last run was '$lastUpdate' ago"
                      fi



                      Sample Output:



                      <root@ubuntu><~/ubuntu-cookbooks/libraries>
                      # runAptGetUpdate

                      Skip apt-get update because its last run was '0h 37m 43s' ago


                      I extracted these functions from my personal github: https://github.com/gdbtek/ubuntu-cookbooks/blob/master/libraries/util.bash







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Jul 29 '15 at 20:10









                      Community

                      1




                      1










                      answered Feb 23 '15 at 20:33









                      Nam NguyenNam Nguyen

                      21635




                      21635





















                          2














                          You may also interested about the file:



                          /var/log/apt/term.log


                          Open it with less or cat as root.






                          share|improve this answer























                          • This is a sensible place to check for logs of actions apt has performed on the package database, but afaik the poster wants to know about apt-get update, and that is obviously not logged.

                            – Faheem Mitha
                            Mar 12 '14 at 16:00















                          2














                          You may also interested about the file:



                          /var/log/apt/term.log


                          Open it with less or cat as root.






                          share|improve this answer























                          • This is a sensible place to check for logs of actions apt has performed on the package database, but afaik the poster wants to know about apt-get update, and that is obviously not logged.

                            – Faheem Mitha
                            Mar 12 '14 at 16:00













                          2












                          2








                          2







                          You may also interested about the file:



                          /var/log/apt/term.log


                          Open it with less or cat as root.






                          share|improve this answer













                          You may also interested about the file:



                          /var/log/apt/term.log


                          Open it with less or cat as root.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jan 29 '14 at 16:43









                          Abdelraouf AdjalAbdelraouf Adjal

                          644




                          644












                          • This is a sensible place to check for logs of actions apt has performed on the package database, but afaik the poster wants to know about apt-get update, and that is obviously not logged.

                            – Faheem Mitha
                            Mar 12 '14 at 16:00

















                          • This is a sensible place to check for logs of actions apt has performed on the package database, but afaik the poster wants to know about apt-get update, and that is obviously not logged.

                            – Faheem Mitha
                            Mar 12 '14 at 16:00
















                          This is a sensible place to check for logs of actions apt has performed on the package database, but afaik the poster wants to know about apt-get update, and that is obviously not logged.

                          – Faheem Mitha
                          Mar 12 '14 at 16:00





                          This is a sensible place to check for logs of actions apt has performed on the package database, but afaik the poster wants to know about apt-get update, and that is obviously not logged.

                          – Faheem Mitha
                          Mar 12 '14 at 16:00











                          1














                          I use this command



                          stat /var/cache/apt/ | grep -i -e access -e modify



                          to show last time it was accessed ie. running 'apt-get update' also last time it was actually updated.



                          note if the times are different there may not have been an update available. Since I have my updates and upgrades running by crontab at specific times I can tell if my updates ran or not.






                          share|improve this answer



























                            1














                            I use this command



                            stat /var/cache/apt/ | grep -i -e access -e modify



                            to show last time it was accessed ie. running 'apt-get update' also last time it was actually updated.



                            note if the times are different there may not have been an update available. Since I have my updates and upgrades running by crontab at specific times I can tell if my updates ran or not.






                            share|improve this answer

























                              1












                              1








                              1







                              I use this command



                              stat /var/cache/apt/ | grep -i -e access -e modify



                              to show last time it was accessed ie. running 'apt-get update' also last time it was actually updated.



                              note if the times are different there may not have been an update available. Since I have my updates and upgrades running by crontab at specific times I can tell if my updates ran or not.






                              share|improve this answer













                              I use this command



                              stat /var/cache/apt/ | grep -i -e access -e modify



                              to show last time it was accessed ie. running 'apt-get update' also last time it was actually updated.



                              note if the times are different there may not have been an update available. Since I have my updates and upgrades running by crontab at specific times I can tell if my updates ran or not.







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Feb 4 '17 at 17:53









                              SCBBSCBB

                              415




                              415





















                                  1














                                  Combining @ssokolow's last comment with the answer from here, this command will run apt-get update if it hasn't run in the last 7 days:



                                  [ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mtime -7)" ] && sudo apt-get update


                                  Explanation:




                                  • -mtime -7 finds files that have a change time in the last 7 days. You can use -mmin if you care about shorter times.


                                  • -maxdepth 0 ensures find won't go into the contents of the directory.


                                  • -H dereferences /var/lib/apt/lists if it's a soft link

                                  • If for some reason find fails, then the command would run. This seems to me like the safe default. If you want to flip the default, use -n in the test and -mtime +7 in the find command.





                                  share|improve this answer





























                                    1














                                    Combining @ssokolow's last comment with the answer from here, this command will run apt-get update if it hasn't run in the last 7 days:



                                    [ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mtime -7)" ] && sudo apt-get update


                                    Explanation:




                                    • -mtime -7 finds files that have a change time in the last 7 days. You can use -mmin if you care about shorter times.


                                    • -maxdepth 0 ensures find won't go into the contents of the directory.


                                    • -H dereferences /var/lib/apt/lists if it's a soft link

                                    • If for some reason find fails, then the command would run. This seems to me like the safe default. If you want to flip the default, use -n in the test and -mtime +7 in the find command.





                                    share|improve this answer



























                                      1












                                      1








                                      1







                                      Combining @ssokolow's last comment with the answer from here, this command will run apt-get update if it hasn't run in the last 7 days:



                                      [ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mtime -7)" ] && sudo apt-get update


                                      Explanation:




                                      • -mtime -7 finds files that have a change time in the last 7 days. You can use -mmin if you care about shorter times.


                                      • -maxdepth 0 ensures find won't go into the contents of the directory.


                                      • -H dereferences /var/lib/apt/lists if it's a soft link

                                      • If for some reason find fails, then the command would run. This seems to me like the safe default. If you want to flip the default, use -n in the test and -mtime +7 in the find command.





                                      share|improve this answer















                                      Combining @ssokolow's last comment with the answer from here, this command will run apt-get update if it hasn't run in the last 7 days:



                                      [ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mtime -7)" ] && sudo apt-get update


                                      Explanation:




                                      • -mtime -7 finds files that have a change time in the last 7 days. You can use -mmin if you care about shorter times.


                                      • -maxdepth 0 ensures find won't go into the contents of the directory.


                                      • -H dereferences /var/lib/apt/lists if it's a soft link

                                      • If for some reason find fails, then the command would run. This seems to me like the safe default. If you want to flip the default, use -n in the test and -mtime +7 in the find command.






                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited May 23 '17 at 12:39









                                      Community

                                      1




                                      1










                                      answered Apr 13 '17 at 9:41









                                      itsadokitsadok

                                      1,66542126




                                      1,66542126





















                                          0














                                          I just posted an answer to this question on following topic



                                          Where can I look up my update history?



                                          The answer may be less appropriate for this topic, as it specifically looks for "apt-get upgrade". Here's sample output.



                                          xenial% 9: ./linuxpatchdate 
                                          2016-07-19 54
                                          2017-02-24 363
                                          2017-03-08 7
                                          2017-03-09 2


                                          See the other topic for source code and more explanation.






                                          share|improve this answer

























                                          • It looked to me like your code looked for upgrade, not update. For example, I just ran "apt-get update" (the subject of this question) on my Ubuntu 16.04 and not one iota of change appears in /var/log/apt, implying that scanning anything in that directory will be of no use in answer this particular question.

                                            – Ron Burk
                                            May 1 '17 at 20:56






                                          • 1





                                            You're totally right. Thanks for pointing that out. I've changed my answer to reflect that. We were looking for the last date updates were applied to the machine, rather than updates being just downloaded.

                                            – JsinJ
                                            May 4 '17 at 4:40















                                          0














                                          I just posted an answer to this question on following topic



                                          Where can I look up my update history?



                                          The answer may be less appropriate for this topic, as it specifically looks for "apt-get upgrade". Here's sample output.



                                          xenial% 9: ./linuxpatchdate 
                                          2016-07-19 54
                                          2017-02-24 363
                                          2017-03-08 7
                                          2017-03-09 2


                                          See the other topic for source code and more explanation.






                                          share|improve this answer

























                                          • It looked to me like your code looked for upgrade, not update. For example, I just ran "apt-get update" (the subject of this question) on my Ubuntu 16.04 and not one iota of change appears in /var/log/apt, implying that scanning anything in that directory will be of no use in answer this particular question.

                                            – Ron Burk
                                            May 1 '17 at 20:56






                                          • 1





                                            You're totally right. Thanks for pointing that out. I've changed my answer to reflect that. We were looking for the last date updates were applied to the machine, rather than updates being just downloaded.

                                            – JsinJ
                                            May 4 '17 at 4:40













                                          0












                                          0








                                          0







                                          I just posted an answer to this question on following topic



                                          Where can I look up my update history?



                                          The answer may be less appropriate for this topic, as it specifically looks for "apt-get upgrade". Here's sample output.



                                          xenial% 9: ./linuxpatchdate 
                                          2016-07-19 54
                                          2017-02-24 363
                                          2017-03-08 7
                                          2017-03-09 2


                                          See the other topic for source code and more explanation.






                                          share|improve this answer















                                          I just posted an answer to this question on following topic



                                          Where can I look up my update history?



                                          The answer may be less appropriate for this topic, as it specifically looks for "apt-get upgrade". Here's sample output.



                                          xenial% 9: ./linuxpatchdate 
                                          2016-07-19 54
                                          2017-02-24 363
                                          2017-03-08 7
                                          2017-03-09 2


                                          See the other topic for source code and more explanation.







                                          share|improve this answer














                                          share|improve this answer



                                          share|improve this answer








                                          edited May 4 '17 at 4:39

























                                          answered Mar 11 '17 at 0:00









                                          JsinJJsinJ

                                          212




                                          212












                                          • It looked to me like your code looked for upgrade, not update. For example, I just ran "apt-get update" (the subject of this question) on my Ubuntu 16.04 and not one iota of change appears in /var/log/apt, implying that scanning anything in that directory will be of no use in answer this particular question.

                                            – Ron Burk
                                            May 1 '17 at 20:56






                                          • 1





                                            You're totally right. Thanks for pointing that out. I've changed my answer to reflect that. We were looking for the last date updates were applied to the machine, rather than updates being just downloaded.

                                            – JsinJ
                                            May 4 '17 at 4:40

















                                          • It looked to me like your code looked for upgrade, not update. For example, I just ran "apt-get update" (the subject of this question) on my Ubuntu 16.04 and not one iota of change appears in /var/log/apt, implying that scanning anything in that directory will be of no use in answer this particular question.

                                            – Ron Burk
                                            May 1 '17 at 20:56






                                          • 1





                                            You're totally right. Thanks for pointing that out. I've changed my answer to reflect that. We were looking for the last date updates were applied to the machine, rather than updates being just downloaded.

                                            – JsinJ
                                            May 4 '17 at 4:40
















                                          It looked to me like your code looked for upgrade, not update. For example, I just ran "apt-get update" (the subject of this question) on my Ubuntu 16.04 and not one iota of change appears in /var/log/apt, implying that scanning anything in that directory will be of no use in answer this particular question.

                                          – Ron Burk
                                          May 1 '17 at 20:56





                                          It looked to me like your code looked for upgrade, not update. For example, I just ran "apt-get update" (the subject of this question) on my Ubuntu 16.04 and not one iota of change appears in /var/log/apt, implying that scanning anything in that directory will be of no use in answer this particular question.

                                          – Ron Burk
                                          May 1 '17 at 20:56




                                          1




                                          1





                                          You're totally right. Thanks for pointing that out. I've changed my answer to reflect that. We were looking for the last date updates were applied to the machine, rather than updates being just downloaded.

                                          – JsinJ
                                          May 4 '17 at 4:40





                                          You're totally right. Thanks for pointing that out. I've changed my answer to reflect that. We were looking for the last date updates were applied to the machine, rather than updates being just downloaded.

                                          – JsinJ
                                          May 4 '17 at 4:40











                                          0














                                          LAST_UPDATED=$( stat --format="%X" /var/cache/apt/pkgcache.bin )
                                          UNIX_TIME=$( date +%s )
                                          TIME_DIFF=$(( UNIX_TIME - LAST_UPDATED ))

                                          if [[ "$TIME_DIFF" -gt 43200 ]]
                                          then
                                          # It's been 12 hours since apt-get update was ran.
                                          fi





                                          share|improve this answer



























                                            0














                                            LAST_UPDATED=$( stat --format="%X" /var/cache/apt/pkgcache.bin )
                                            UNIX_TIME=$( date +%s )
                                            TIME_DIFF=$(( UNIX_TIME - LAST_UPDATED ))

                                            if [[ "$TIME_DIFF" -gt 43200 ]]
                                            then
                                            # It's been 12 hours since apt-get update was ran.
                                            fi





                                            share|improve this answer

























                                              0












                                              0








                                              0







                                              LAST_UPDATED=$( stat --format="%X" /var/cache/apt/pkgcache.bin )
                                              UNIX_TIME=$( date +%s )
                                              TIME_DIFF=$(( UNIX_TIME - LAST_UPDATED ))

                                              if [[ "$TIME_DIFF" -gt 43200 ]]
                                              then
                                              # It's been 12 hours since apt-get update was ran.
                                              fi





                                              share|improve this answer













                                              LAST_UPDATED=$( stat --format="%X" /var/cache/apt/pkgcache.bin )
                                              UNIX_TIME=$( date +%s )
                                              TIME_DIFF=$(( UNIX_TIME - LAST_UPDATED ))

                                              if [[ "$TIME_DIFF" -gt 43200 ]]
                                              then
                                              # It's been 12 hours since apt-get update was ran.
                                              fi






                                              share|improve this answer












                                              share|improve this answer



                                              share|improve this answer










                                              answered Nov 17 '18 at 0:21









                                              mikeytown2mikeytown2

                                              1012




                                              1012



























                                                  draft saved

                                                  draft discarded
















































                                                  Thanks for contributing an answer to Ask Ubuntu!


                                                  • Please be sure to answer the question. Provide details and share your research!

                                                  But avoid


                                                  • Asking for help, clarification, or responding to other answers.

                                                  • Making statements based on opinion; back them up with references or personal experience.

                                                  To learn more, see our tips on writing great answers.




                                                  draft saved


                                                  draft discarded














                                                  StackExchange.ready(
                                                  function ()
                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f410247%2fhow-to-know-last-time-apt-get-update-was-executed%23new-answer', 'question_page');

                                                  );

                                                  Post as a guest















                                                  Required, but never shown





















































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown

































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown







                                                  Popular posts from this blog

                                                  Tamil (spriik) Luke uk diar | Nawigatjuun

                                                  Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

                                                  Training a classifier when some of the features are unknownWhy does Gradient Boosting regression predict negative values when there are no negative y-values in my training set?How to improve an existing (trained) classifier?What is effect when I set up some self defined predisctor variables?Why Matlab neural network classification returns decimal values on prediction dataset?Fitting and transforming text data in training, testing, and validation setsHow to quantify the performance of the classifier (multi-class SVM) using the test data?How do I control for some patients providing multiple samples in my training data?Training and Test setTraining a convolutional neural network for image denoising in MatlabShouldn't an autoencoder with #(neurons in hidden layer) = #(neurons in input layer) be “perfect”?