I'm running a slice of ubuntu hardy.
I've installed sphinx, and I would like to run the sphinx indexer every x
minutes.
What is the best way to go about doing this?
rashcroft
问问题
1674 次
2 回答
5
标准的 Unix 方法是cron
,因此您可以例如编辑/etc/crontab
并添加一行
*/5 * * * * root sphynx [whatever other options you need]
意思是
- '每五分钟'(对于 */5 部分)
- 每小时(位置 2 中的 *)
- 每月的每一天(位置 3 中的 *)
- 每个月(位置 4 中的 *)
- 一周中的每一天(第 5 位的最后一个 *)
另一个例子:'4 5 * * 6' 等于'at 5:04am(五点后四分钟)每周六(一周中的第 6 天)。
您可能需要或想要将用户从 root 切换到,例如 www-data is sphynx 运行,您显然需要调整参数。
最后,查看目录
$ ls -1d /etc/cron.*
/etc/cron.d
/etc/cron.daily
/etc/cron.hourly
/etc/cron.monthly
/etc/cron.weekly
例如 --- 其他软件包将它们的工作放在那里(而且这种机制比直接编辑/etc/crontab
.
于 2009-08-02T20:19:21.987 回答
2
这是我重新索引然后每天重新启动一次搜索守护程序的方法。
* * /1 * * root cd /home/sphinx && bin/indexer --all --rotate && bin/searchd --stop && bin/searchd
于 2011-09-16T16:25:46.837 回答