如何启用定位和排队要构建的数据库?


37

在新的Ubuntu 10.4实例上,我尝试locate仅使用命令来接收错误

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

在其他系统上使用此命令时,我猜测这意味着尚未构建数据库(这是全新安装)。我相信它应该每天运行,但是我应该如何排队使其立即运行?

另外,如何确定“每日运行”?如果我有一个仅一次打开一个小时的盒子,那么数据库是否会自己建立?

Answers:


58

cron作业在中定义/etc/cron.daily/mlocate

要立即运行:

sudo updatedb

或更好

sudo ionice -c3 updatedb

这样做更好,因为updatedb是在Idle I / O调度类中设置的,因此它不会干扰(从I / O角度而言)其他应用程序。从ionice手册页:

  -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).

谢谢。为什么第二个更好?
cwd

@cwd:请参阅更新的答案。
enzotib 2011年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.