43

On a new Ubuntu 10.4 instance, I tried to use the locate command only to receive the error

locate: can not stat () `/var/lib/mlocate/mlocate.db': No such file or directory

from using this command on other systems I'm guessing that this means the database has not yet been built (it is a fresh install). I believe it is supposed to run daily, but how would I queue it up to run immediately?

Also, how is "run daily" determined? If I have a box that I only turn on for an hour at a time will the database ever be built on it's own?

1 Answer 1

67

The cron job is defined in /etc/cron.daily/mlocate.

To run it immediately:

sudo updatedb

or better

sudo ionice -c3 updatedb

This is better because updatedb is set in the Idle I/O scheduling class, so that it do not disturb (from the I/O point of view) other applications. From ionice man page:

  -c class
          The scheduling class. 0 for none, 1 for real time, 2 for 
          best-effort, 3 for idle.

  ........................

  Idle   A program running with idle io priority will only get disk time
         when no other  program  has  asked  for disk io for a defined 
         grace period. The impact of idle io processes on normal system 
         activity should be zero. This scheduling class does not take a 
         priority argument. Presently, this scheduling class is permitted 
         for an ordinary user (since kernel 2.6.25).
3
  • Thanks. Why is the second one better?
    – cwd
    Commented Dec 6, 2011 at 17:24
  • 1
    @cwd: see updated answer.
    – enzotib
    Commented Dec 6, 2011 at 17:36
  • This worked for me as well Commented Mar 20, 2020 at 9:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .