Interview Prep/Linux/Patching, Automation & Golden Images

How do you handle "Could not get lock /var/lib/dpkg/lock-frontend" in automation?

IntermediateProductionPatching, Automation & Golden Images
Answer

Another apt process holds the lock, often unattended-upgrades or cloud-init on a fresh instance. Do not delete lock files. Wait for it:

cloud-init status --wait
while sudo fuser /var/lib/dpkg/lock-frontend >/dev/null 2>&1; do sleep 5; done

apt-get also supports -o DPkg::Lock::Timeout=300. In images, disable automatic upgrades on first boot if your pipeline handles patching.

All Linux questions Roadmap: Linux

More on Patching, Automation & Golden Images