views:

193

answers:

2

Hi,

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?

+1  A: 

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

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

use strict;
use warnings;

use Proc::Daemon;

Proc::Daemon::Init;

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

while (1) {
    sleep($seconds);
    # Do necessary work
}
Alan Haggai Alavi
+1  A: 

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.

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

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