How do I check to see if an apt lock file is locked?
Posted
by
gondoi
on Server Fault
See other posts from Server Fault
or by gondoi
Published on 2011-01-13T03:32:04Z
Indexed on
2011/01/13
3:55 UTC
Read the original article
Hit count: 249
I am writing a script to do some apt commands, but I am running into potential issues of the apt/dpkg databases being locked so my script bails. I want to check the lock files (i.e. /var/lib/dpkg/lock) before doing anything just like apt does when it runs it's command, but I can't figure out how apt is performing the lock.
The lock file is always there, and apt-get is not doing a flock on the file. How else would it be checking to see if it is in use? From an strace I see that apt-get opens the file, but that is it. In my script, I can open the file while apt-get has it open as well.
© Server Fault or respective owner