I remember messing around with crontab and setting up email capabilities on a server many months back, and now all of a sudden I'm getting the following email:


from:    root <myemail@gmail.com>
to:  root
date:    Thu, Dec 5, 2013 at 6:48 AM
subject:     Cron <root@server-ip> test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
mailed-by:   gmail.com


/usr/bin/updatedb.mlocate: `/var/lib/mlocate/mlocate.db' is locked (probably by an earlier updatedb)
run-parts: /etc/cron.daily/mlocate exited with return code 1

This is a cron job that updates the indexes for mlocate, which is used when you run locate on your system to find files. This index allows the program to quickly find files without traversing the filesystem (which is much more expensive, because it's not optimised for that use case). For some reason, the lock file that stops more than one database update happening at one time still remains, perhaps because mlocate was terminated unexpectedly and wasn't able to remove the lock file.

To fix this:

  • Check that there are no updatedb.mlocate processes running (pgrep -x 'updatedb\.mlocate');
  • If one is running, either wait for it to finish, or if you think it is stuck, terminate it (pkill -x 'updatedb\.mlocate', perhaps using more violent signals if there is no response);
  • Remove the lock if none are running (rm /var/lib/mlocate/*.lock).
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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