Reputation: 101
Whenever an AWS autoscaling group launches new ubuntu instance and I try to install any package on that instance it gives me the following error:
[stderr]E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
[stderr]E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend),
Is there another process using it?
I tried to find a solution and manually fixed it but I don't know why whenever the autoscaling group launches a new ubuntu instance it gives the following error.
Upvotes: 1
Views: 905
Reputation: 8890
SSH into the instance before/while the UserData is running and check which process has acquired the lock:
$ lsof /var/lib/dpkg/lock-frontend
Also, try to enable CodeDeploy agent at the last step after performing all other steps in UserData, like:
Upvotes: 0
Reputation: 151
When any command updates the Ubuntu or installs a new application, it locks the dpkg(Debian Package Manager). To identify the problem, please look at the logs
journalctl -u apt-daily.service
. This usually happend when the system is set to update itslef and you will notice such activity with this ps -ef | grep apt.systemd.daily
and you can check these setting in the file /etc/apt/apt.conf.d/20auto-upgrades
/var/log/dpkg.log*
(as it may get rotated) check these logs to find which all services were trying to get installedOnce you have identified the problem, you can solve with these methods:
--user-data
of your bootstrapping scriptA snippet of code from the referenced link:
until service codedeploy-agent status >/dev/null 2>&1; do
sleep 60
rm -f install
wget https://aws-codedeploy-us-west-2.s3.amazonaws.com/latest/install
chmod +x ./install
sudo ./install auto
service codedeploy-agent restart
done
Upvotes: 1