If running apt-get (or aptitude) and you get the following error:
$ apt-get update E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable) E: Unable to lock the list directory |
Then (most likely) explenation is that one of the sources have gotten a timeout and that a (cron) sheduled update task have gotten locked.
A simple solution for this is to find the cron process is locked, and kill it.
$ ps -a |grep apt Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html 3737 ? SN 0:00 /bin/sh /etc/cron.daily/apt 3833 ? SN 0:00 apt-get -qq -y update -o APT::Update::Auth-Failure::=cp /usr/share/apt/apt-auth-failure.note /var/lib/update-notifier/user.d/ 3835 ? SN 0:00 /usr/lib/apt/methods/http 3838 ? SN 0:00 /usr/lib/apt/methods/http 3842 ? SN 0:00 /usr/lib/apt/methods/http 3869 ? SN 0:00 /usr/lib/apt/methods/http 4223 pts/0 R+ 0:00 grep apt $ kill -9 3833 |
If this happens often, then perhaps you should try to debug the sources and remove (or exchange) the source that is causing the problems.
Either something is installing in the background or your system was suspended and the lock files remain in use on the system.
Type lsof | grep -i l/var/lib/apt/lists/lock
Look in the number in the second column and that is the process id. You either need to shut it down or you can kill it by
sudo kill -9 process_id
That should help