每隔几分钟重新索引一次搜索引擎

时间:2021-08-24 02:54:15

I'm running a search service on my development computer, and I have to run an indexer (.exe file) and restart a service every 1-5 minutes (I'm using sphinx search). How would I go about doing this in Windows? My thought is to run a batch file through windows task scheduler, but what do you do?

我正在我的开发计算机上运行搜索服务,我必须运行索引器(.exe文件)并每1-5分钟重启一次服务(我正在使用sphinx搜索)。我将如何在Windows中执行此操作?我的想法是通过Windows任务调度程序运行批处理文件,但你怎么办?

2 个解决方案

#1


Use Windows Task Scheduler while in Windows. Use cron while in Linux.

在Windows中使用Windows任务计划程序。在Linux中使用cron。

Otherwise, you could write a daemon process which would sleep in an infinite loop for a specified interval and re-index once the interval is over. Then again, it would sleep and continue the process.

否则,您可以编写一个守护程序进程,它将在无限循环中睡眠一段指定的时间间隔,并在间隔结束后重新编制索引。然后,它会睡觉并继续这个过程。

For example (in Perl):

例如(在Perl中):

#!perl

use strict;
use warnings;

use Proc::Daemon;

Proc::Daemon::Init;

my $minutes = 5;
my $seconds = 60 * $minutes;

while (1) {
    sleep($seconds);
    # Do necessary work
}

#2


I found pycron quite helpful as a replacement for the built in task scheduler. If you are used to the unix cron style you'll love it from the beginnig. It has an editable config file and logfiles and more options.

我发现pycron非常有用,可以替代内置的任务调度程序。如果你习惯了unix cron风格,那么你会从初学者那里得到它。它有一个可编辑的配置文件和日志文件以及更多选项。

An article about it: http://www.bigbluehost.com/article4.html

一篇关于它的文章:http://www.bigbluehost.com/article4.html

Pycron's website: http://www.kalab.com/freeware/pycron/pycron.htm

Pycron的网站:http://www.kalab.com/freeware/pycron/pycron.htm

#1


Use Windows Task Scheduler while in Windows. Use cron while in Linux.

在Windows中使用Windows任务计划程序。在Linux中使用cron。

Otherwise, you could write a daemon process which would sleep in an infinite loop for a specified interval and re-index once the interval is over. Then again, it would sleep and continue the process.

否则,您可以编写一个守护程序进程,它将在无限循环中睡眠一段指定的时间间隔,并在间隔结束后重新编制索引。然后,它会睡觉并继续这个过程。

For example (in Perl):

例如(在Perl中):

#!perl

use strict;
use warnings;

use Proc::Daemon;

Proc::Daemon::Init;

my $minutes = 5;
my $seconds = 60 * $minutes;

while (1) {
    sleep($seconds);
    # Do necessary work
}

#2


I found pycron quite helpful as a replacement for the built in task scheduler. If you are used to the unix cron style you'll love it from the beginnig. It has an editable config file and logfiles and more options.

我发现pycron非常有用,可以替代内置的任务调度程序。如果你习惯了unix cron风格,那么你会从初学者那里得到它。它有一个可编辑的配置文件和日志文件以及更多选项。

An article about it: http://www.bigbluehost.com/article4.html

一篇关于它的文章:http://www.bigbluehost.com/article4.html

Pycron's website: http://www.kalab.com/freeware/pycron/pycron.htm

Pycron的网站:http://www.kalab.com/freeware/pycron/pycron.htm