![如何启用要构建的数据库的定位和排队?](https://linux22.com/image/19271/%E5%A6%82%E4%BD%95%E5%90%AF%E7%94%A8%E8%A6%81%E6%9E%84%E5%BB%BA%E7%9A%84%E6%95%B0%E6%8D%AE%E5%BA%93%E7%9A%84%E5%AE%9A%E4%BD%8D%E5%92%8C%E6%8E%92%E9%98%9F%EF%BC%9F.png)
在新的 Ubuntu 10.4 实例上,我尝试使用该locate
命令仅收到错误
locate: can not stat () `/var/lib/mlocate/mlocate.db': No such file or directory
在其他系统上使用此命令我猜测这意味着数据库尚未构建(它是全新安装)。我相信它应该每天运行,但我如何将其排队以立即运行?
另外,“每日运行”是如何确定的?如果我有一个每次只打开一个小时的盒子,数据库会自己构建吗?
答案1
cron 作业在 中定义/etc/cron.daily/mlocate
。
要立即运行它:
sudo updatedb
或更好
sudo ionice -c3 updatedb
这更好,因为updatedb
设置在空闲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).