6

I can clear the cache with yum clean all or, more quickly, with yum clean expire-cache.

However, without actually clearing the cache, I would simply like to find out when the cache will expire on its own.

How can I find out when yum's metadata is set to expire?


I use CFEngine for self-healing infrastructure so the packages that should be installed on the servers I am handling, will be installed, shortly after yum clean expire-cache is run. I've tested this. If I can check the metadata expiration time on one of the servers that I haven't run yum clean expire-cache on, I will have some idea of when these servers will self-heal.

Wildcard
  • 36,499

2 Answers2

10

yum repolist enabled -v contains this information (the metadata_expire configured and the last metadata update time) and pretty output.

[root@localhost ~]# yum repolist enabled -v | grep 'Repo-name\|expire'
Repo-name    : CentOS-7 - Base
Repo-expire  : 21,600 second(s) (last: Wed Mar  8 19:01:59 2017)
Repo-name    : CentOS-7 - Extras
Repo-expire  : 21,600 second(s) (last: Wed Mar  8 19:02:00 2017)
Repo-name    : CentOS-7 - Updates
Repo-expire  : 21,600 second(s) (last: Wed Mar  8 19:02:01 2017)

Checking the modified time on the cachecookie is another method to get the last metadata update time. This executes very fast, but the yum cache path may not be consistent between distros/majors.

[root@localhost ~]# stat -c %y /var/cache/yum/x86_64/7/base/cachecookie
2017-03-08 19:01:59.650838052 +0000
Matt Cover
  • 111
  • 1
  • 2
6

It is documented in the manual page for yum.conf:

metadata_expire
Time (in seconds) after which the metadata will expire. So that if the current metadata downloaded is less than this many seconds old then yum will not update the metadata against the repository. If you find that yum is not downloading information on updates as often as you would like lower the value of this option. You can also change from the default of using seconds to using days, hours or minutes by appending a d, h or m respectively. The default is 6 hours, to compliment yum-updatesd running once an hour. It's also possible to use the word "never", meaning that the metadata will never expire. Note that when using a metalink file the metalink must always be newer than the metadata for the repository, due to the validation, so this timeout also applies to the metalink file.

(The misspelling is in the manual page: no need to correct it here).

Thomas Dickey
  • 76,765