I'm trying to make a script to setup a new VM to be ready for use, which involves some installs, but when I put the install commands (
apt-get --yes install <package>) in the a script they always fail with:
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
The script is run as root (
When I check for
apt process I get:
4 S root 2227 1 0 80 0 - 1126 - 07:33 ? 00:00:00 /bin/sh /usr/lib/apt/apt.systemd.daily update 0 S root 2231 2227 0 80 0 - 1126 - 07:33 ? 00:00:00 /bin/sh /usr/lib/apt/apt.systemd.daily lock_is_held update
The thing is, this only happens when apts are executed from a script, if I execute exactly the same commands manually they never have this problem. Does the shell script run apt installs differently somehow?
In any case, what is the best way to run
yum for that matter) installer from a shell script in a way that woudn't cause it to lock up?