在 CentOS/RHEL 7 中,Yum 命令报错“Existing lock, Another app is currently holding the yum lock”
之路 on it Road.com

解决方法

安装在系统中的 GUI PackageKit 实用程序,并在定期运行时持有 yum 锁。
我们可以使用下面给出的任何一种方法来解决错误。
有时,杀死 PackageKit 实用程序使用的进程 ID 不起作用。
在这种情况下,唯一的解决方案是禁用 PackageKit 或者完全删除它。

方法一:杀死PackageKit使用的进程ID

杀死持有 yum 锁的进程,例如:

# kill -9 13023

或者

# pkill PackageKit

然后再次运行 yum 命令。

删除/禁用 PackageKit 实用程序

另一种方法是通过编辑 refresh-packagekit 配置文件 /etc/yum/pluginconf.d/refresh-packagekit.conf 来禁用 refresh-packagekit yum 插件:

[main]
enabled=0

或者我们可以从系统中删除 PackageKit 管理实用程序:

# yum remove -y PackageKit*

问题

执行 yum 命令时,我们会收到如下所示的错误:

# yum list
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 2017 - 00:33 ago
    State  : Sleeping, pid: 13023

该错误表明另一个实例正在运行 yum update ,它的 PID 是 13023.
检查 'ps -ef' 命令中的 PID 以查看哪个进程持有 yum 锁。

# ps -ef | grep 13023
root      13023  11813  3 18:31 ?        00:00:04 /usr/bin/python /usr/share/PackageKit/helpers/yum/yumBackend.py refresh-cache yes
日期:2020-09-17 00:14:15 来源:oir作者:oir