We’ve explored the yum package manager for RHEL based systems extensively in previous yum. In this article, we will present the cause and fix for the message “Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast” which you might occassionally come across while running yum commands.
Cause of the message
YUM maintains a cache of repository related information in the /var/cache/yum/$basearch/$releasever/ directory, where $basearch and $releasever are Yum variables referring to base architecture of the system and the release version of Red Hat Enterprise Linux. Along with some metadata yum also stores downloaded packages temporarily in this location while the packages are being installed. Once the packages are installed successfully they are removed from the cache directories. If you are working on a server that has not been able to connect to an active yum repository server for several weeks then you will see this message when you run a yum command indicating the presence of outdated repository entries in the yum cache.This basically means that the yum cache directory is not up to date.
[root@linuxnix ~]# yum install zip Loaded plugins: fastestmirror, langpacks Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
The old repodata warning also gets triggered if you restore from an old server snapshots for those using VPS servers or cloud servers. It is merely a warning that you may not be getting the current version of programs for your webserver.
Fix for the message:
You can get rid of this message via one of the following two methods.
Method 1; Yum clean all
To clean the yum cache entirely and recreate it execute the following command:
[root@linuxnix ~]# yum clean all Loaded plugins: fastestmirror, langpacks Cleaning repos: base epel extras puppetlabs-pc1 updates Cleaning up everything Cleaning up list of fastest mirrors [root@linuxnix ~]#
After running this command, when you run the next yum related command then it will populate the yum cache again, you will no longer see the “Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast” since yum will now have access to the latest repository metadata in the yum cache.
Method 2: Yum makecache fast
The yum cache will be automatically built up over time when you perform various yum queries such as installing or updating packages, however we have the option to manually make the cache so that future actions will be quicker with the ‘makecache’ argument. By adding the keyword fast to the end of the yum makecache command will make it populate the yum cache even faster but will end up caching fewer repositories.
[root@linuxnix ~]# yum makecache fast Loaded plugins: fastestmirror, langpacks base | 3.6 kB 00:00:00 epel/x86_64/metalink | 5.3 kB 00:00:00 epel | 4.7 kB 00:00:00 extras | 3.4 kB 00:00:00 puppetlabs-pc1 | 2.5 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/8): base/7/x86_64/group_gz | 166 kB 00:00:05 (2/8): extras/7/x86_64/primary_db | 186 kB 00:00:03 (3/8): puppetlabs-pc1/x86_64/primary_db | 184 kB 00:00:03 (4/8): epel/x86_64/group_gz | 88 kB 00:00:13 (5/8): epel/x86_64/updateinfo | 938 kB 00:00:22 (6/8): base/7/x86_64/primary_db | 5.9 MB 00:00:48 (7/8): epel/x86_64/primary | 3.6 MB 00:01:40 (8/8): updates/7/x86_64/primary_db | 5.2 MB 00:01:57 Determining fastest mirrors * base: centos.mirror.snu.edu.in * epel: mirror01.idc.hinet.net * extras: mirrors.nhanhoa.com * updates: mirrors.viethosting.com epel 12661/12661 Metadata Cache Created [root@linuxnix ~]#
Aside from the two methods described above we could also use yum-cron to regularly refresh the yum cache. The yum-cron package provides a convenient way to check for, download and apply updates automatically.The cron jobs from the yum-cron package are active immediately after installing the package and there’s no extra configuration necessary. The job will be run when daily cron jobs are set to run.
This concludes our description and fix for the message “YUM: Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast”. We hope that you found this article to be useful and we look forward towards your suggestions and feedback.
Latest posts by Sahil Suri (see all)
- Setting up chrooted ssh jails in Linux - October 8, 2019
- How To exclude copying of specific directories in Linux using cp/scp/rsync - October 7, 2019
- Docker container ports explained - September 27, 2019
- Docker Volumes explained - September 25, 2019
- Docker networking commands explained - September 24, 2019