Last active
February 17, 2022 13:09
-
-
Save lucasrangit/53727223d33fa8d876936e467f9de3da to your computer and use it in GitHub Desktop.
Monitor DPKG lock file to determine which command acquired it and list its parent tree to determine why/how it was executed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -o xtrace | |
set -o errexit | |
set -o pipefail | |
while true; do | |
pid=$(set +o pipefail; sudo fuser /var/lib/dpkg/lock-frontend 2>&1 | grep -o "[0-9]*" | head -n 1) | |
if [[ ! -z $pid ]]; then | |
sudo pstree -sa $pid | |
fi | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output looks like this. Showing that it is the daily unattended upgrade cron job that is locking
dpkg
.