如果之前有一个apt或apt-get进程正在运行,之后的apt将无法运行,并提示
Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 43843 (unattended-upgrade)
但此错误信息批处理里可能看不到。
此时需要终止该进程,才能运行下一个apt程序
kill -9 43843
预警检查:
apt-get check >/dev/null 2>&1
if [ "$?" -ne 0 ]; then
echo "you may have broken packages. Aborting..."
fi
或
fuser /var/lib/dpkg/lock
fuser /var/lib/dpkg/lock-frontend
disable unattended-upgrade
https://gist.github.com/plembo/428068f16e6f15c93959ff5448a50e0b
# cat /etc/apt/apt.conf.d/20auto-upgrades
APT
eriodic::Update-Package-Lists "0";
APT
eriodic::Unattended-Upgrade "0";