If you are working with Linux environment, you must have once in your carrier ended up with this error "another app is currently holding the yum lock" or "Existing lock /var/run/yum.pid: another copy is running as pid XXX" while executing yum. I mostly use RHEL/CentOS environment in my work life so will only talk about this distribution. But i can say with some confidence that the same steps should work with SuSE environment.
Now this error "
another app is currently holding the yum lock" is seen mostly with older yum versions especially with YUMv3 which was part of RHEL/CentOS 6 and also some versions of RHEL/CentOS 7. Now with RHEL 7.7, Red Hat has moved to YUMv4. We will discuss about the change in later part of this article.
For now let's see how you can overcome and fix "
another app is currently holding the yum lock" error. For the sake of this article I have manually simulated this error by running two parallel yum sessions on different terminals using RHEL/CentOS 7.
Method 1: Kill the locked process to fix "another app is currently holding the yum lock"
Now it is obvious that another session of yum is in progress which is why your yum session is not allowed to run and is waiting for another one to exit. Now until the other yum process exits, your yum process will continue to throw "another app is currently holding the yum lock" as shown below:
# yum install sntp.x86_64 Loaded plugins: fastestmirror Existing lock /var/run/yum.pid: another copy is running as pid 9571. Another app is currently holding the yum lock; waiting for it to exit... The other application is: yum Memory : 86 M RSS (408 MB VSZ) Started: Thu Feb 6 20:44:53 2020 - 00:35 ago State : Sleeping, pid: 9571 Another app is currently holding the yum lock; waiting for it to exit... The other application is: yum Memory : 86 M RSS (408 MB VSZ) Started: Thu Feb 6 20:44:53 2020 - 00:37 ago State : Sleeping, pid: 9571
Now the output itself states the PID of another process which is using
/var/run/yum.pid or you can manually view the content of this file to get the PID of other yum process
# cat /var/run/yum.pid 9571
So we know there is a process with PID "
9571" locking yum. To get more details on this process you can use
ps. Below command will tell you about the command which is using PID 9571
# ps -p 9571 PID TTY TIME CMD 9571 pts/1 00:00:03 yum
To get more details you can use "ps -ef" as shown below
# ps -ef | grep 9571 root 9571 9498 4 20:44 pts/1 00:00:03 /usr/bin/python /usr/bin/yum install nagios-plugins-ntp.x86_64 root 9576 9477 0 20:46 pts/0 00:00:00 grep --color=auto 9571
So there is another session of yum which is installing
nagios-plugins-ntp and hence creating the lock file.
So either you can wait for that process to complete or you can manually kill the process
# kill -9 9571
Now it is also possible that there are some other process which are using yum such as
PackageKit used with RHEL/CentOS 6/7, this may keep the lock for longer period so based on your requirement you can choose to disable this service
To permanently stop and disabling
PackageKit On CentOS/RHEL 7
# systemctl disable packagekit --now
To permanently Disabling
PackageKit On CentOS/RHEL 6 open below file and change
# vi /etc/yum/pluginconf.d/refresh-packagekit.conf enabled=0
Method 2: Use DNF instead of YUM
With CentOS/RHEL 7 we have an alternate tool "
dnf" as a package manager. You must understand that there are major improvements with dnf and should not be considered same as yum.
So if your yum is throwing "
another app is currently holding the yum lock" then you can use dnf as an alternative. But this would require dnf rpm to be installed in your environment which by default will not be installed in RHEL/CentOS 7.
# yum install dnf
Next in future you can completely switch to
dnf but for some reason if someone in your team still uses yum and you get "
another app is currently holding the yum lock" error then you can start using
dnf package manager.
As you see below, both can run in parallel:
# ps -ef | egrep yum\|dnf | grep -v grep root 9626 9498 2 20:59 pts/1 00:00:03 /usr/bin/python /usr/bin/yum install nagios-plugins-ntp.x86_64 root 9628 9477 36 21:00 pts/0 00:00:35 /usr/bin/python2 /usr/bin/dnf install sntp.x86_64
YUM vs DNF
Since we are discussing on this topic, Let us do some brief comparison between YUM and DNF
With RHEL/CentOS 8 they have introduced YUMv4
# rpm -q yum yum-4.2.7-7.el8_1.noarch
Although this will internally be linked with DNFv3.
# ls -l /usr/bin/yum lrwxrwxrwx 1 root root 5 Dec 19 21:13 /usr/bin/yum -> dnf-3
YUMv4 has the following advantages over the previous YUMv3 used on Red Hat Enterprise Linux 7:
- Increased performance
- New features available, most significantly the support for managing the modular content
- Well-designed stable API for integration with tooling
There are various other changes in DNF compared to YUM
dnf you will never face "
another app is currently holding the yum lock" as
dnf does not rely on any such PID file and multiple instances of
dnf can be executed in parallel.
Although if you choose to use YUMv4 you may still get "
Waiting for process with pid XXXX to finish." if another yum process is running but the handling with YUMv4 is far more better than YUMv3
For more details on yum and dnf with RHEL 8
Overview on YUM and DNF in Red Hat
Lastly I hope the steps from the article to fix another app is currently holding the yum lock error on RHEL/CentOS Linux was helpful. So, let me know your suggestions and feedback using the comment section.