While issuing any yum command if you are experiencing the following error:
# yum -y install wget
Loaded plugins: fastestmirror, langpacks
Existing lock /var/run/yum.pid: another copy is running as pid 13023.
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 26 M RSS (430 MB VSZ)
Started: Sat Sep 30 18:31:21 2021 - 00:33 ago
State : Sleeping, pid: 3833
This means that another instance of yum update is running yum update, and you can either wait for the process to finish, or kill it.
Form the output above you can see that the PID in my case is 3833, so let’s use the ps -ef command to see which process is holding the yum lock:
# ps -ef | grep 3833
root 3833 11813 3 18:31 ? 00:00:16 /usr/bin/python /usr/share/PackageKit/helpers/yum/yumBackend.py refresh-cache yes
In my case, a GUI PackageKit utility installed in the system and is holding the yum lock while running regularly. You can use either of the methods given below to resolve the error
NOTE: Sometimes killing the process ID used by PackageKit utility does not work. In that case only solution is to disable PackageKit or remove it completely.
To kill a process use the standard kill command:
# kill -9 3833
or
# pkill PackageKit
To disable PackageKit yum plug-in you can edit the refresh-packagekit configuration file /etc/yum/pluginconf.d/refresh-packagekit.conf :
[main]
enabled=0
and to completely remove the PackageKit utility:
# yum remove -y PackageKit*