0

I have a script that uses apt heavily and currently it faces a locking issue, as:

E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

I want that apt tries to get the lock other than aborting. Is it possible?

2 Answers2

2

As far as I know, getting apt to not lock is impossible. The error is happening because the script is trying to run multiple apt sessions simultaneously. I think it would be best if you could modify the script so that apt operations are run after each other, in a queue maybe.

Wilhelm Erasmus
  • 728
  • 5
  • 24
1

in addition to @Wilhelm's advice (which is good) if you are left with a stale lock file that will not go away (this happens some times) you must remove it manually.

sudo rm -rf /var/lib/dpkg/lock

But be very careful that you have the path exactly correct as the sudo rm -rf will remove files (even system files) in use if you point it to them and can thus permanently break your system.

Wilhelm Erasmus
  • 728
  • 5
  • 24