Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Lately I've been getting a mail from the server every day,

Subject

Cron <root@host> test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )

Body

/etc/cron.daily/apt:
DB Update failed, database locked

If i just run the /etc/cron.daily/apt part it just stays there with no output, i tried running tail -f /var/log/apt/*.log /var/log/syslog & and then running /etc/cron.daily/apt but no output either

Which database is locked and by what, i'm able to do apt-get update successfully.

Did some updates yesterday and had to restart, so the microsoft fix wont work here (this has been going on since before the updates so not related)

What else can I look into?

This is a amazon instance incase it matters

share|improve this question

2 Answers 2

Long story short, change RandomSleep=1800 to something more pleasent. I chose RandomSleep=5

ref: https://lists.ubuntu.com/archives/ubuntu-users/2009-February/175474.html & http://ubuntuforums.org/showthread.php?t=1071892#post_6747612

share|improve this answer
    
This did nothing to fix my problem, which is the same as the OP. If you look at the code, the RandomSleep time is used as a limit for the actual time, which is chosen nominally randomly. Hmm. Looking at the code, there seems to be a bug. RandomSleep is possibly reset to either 1 or 0, by the apt-config call. (If it's even set, mine wasn't.) The apt call either stomps the variable, or does nothing to it. It doesn't actually act on it's value in a useful way. –  Hack Saw Jul 4 '13 at 12:37
    
It seemed to fix my problems for a few days which I think was coincidence more than anything else. –  Bruce Aldridge Jul 4 '13 at 21:38

This happens when you have multiple APT/DPKG instances running at the same time. If you run something that blocks apt-get like aptitude in GUI mode, and type sudo /etc/cron.daily/apt eventually it will fail with the same message.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.