Continously running a script

I am writing a rails script that I need to run continuosly. It
basiclly scans the a particular table in my DB and makes queries to an
outside service and updates the table as needed. I would like to keep
the script constatnly running run. If I write the script as a runner,
is there a way to do this?

Thanks!

By continuously do you mean ‘scan table, scan table, scan table …’ or
‘scan table, wait for 10 minutes, repeat’

If it is the latter then you could simply set up a cron job to run every
few
minutes.

Here’s some details on how you might do it

This sort of thing occurs a few times in my blog.

Hope it might be of help.

Of course this assumes that you are running on *nix or OSX

Actually, I am interested in the former. That is, scan table and once
it is done start form the top again and scan again without any delay.

Thanks for the resource.

On Apr 21, 8:25 am, Peter H. [email protected]

On Apr 21, 7:17 am, “tashfeen.ekram” [email protected] wrote:

Actually, I am interested in the former. That is, scan table and once
it is done start form the top again and scan again without any delay.

http://cr.yp.to/daemontools.html should help (on Unix).

Your Ruby script has an endless loop. daemontools comes in to start it
initially, or if the script fails, or for you to start/stop .

Stephan

On 6 May 2010 18:51, tashfeen.ekram [email protected] wrote:

Thanks!

I can think of a few ways to write a script with a continous loop.
Just wondering though if there is a straight forward way to do it.

while true
Model.all.each do |record|
#… stuff with record
end
end

Writing a continuous loop isn’t hard (I do it myself by mistake all
the time!) - but monitoring it to ensure it’s running is the problem.

Thanks!

I can think of a few ways to write a script with a continous loop.
Just wondering though if there is a straight forward way to do it.

The one way I can think of is to have a integer that is the index of
the record in the DB and then just reset it when it hits the number of
records in the DB.