Thursday, May 1, 2008

Scheduled Tasks with Ruby

I need a scheduled task to run, it needs to query the database once a day, and the rows returned need to have a flag updated. Easy enough. So whats the best way to do it ? The hell if I know.
I found this link - Ruby wiki: running background process
and there were quite a few solutions they provided and these solutions are pretty much what everyone else suggests. Well I guess.. depending on your needs, any of these will work.

The biggest decision would be do you want the process to execute when some action is taken, or do you want it to just fire at specified intervals.

For me I will end up probably using a combination of these, but for my first I will try RunnerScript.
RunnerScript
Execute controller with Runner script

Thinking about it.. I can probably just use curl and fire off some url at the same time using cron ?. No one has mentioned this solution , that i found so far.. but would live under the same restrictions as the rest of these no ?

curl
curl + cron

Edit:06/05/08
http://www.ruby-forum.com/topic/94080
creating a rake task

Notes:

BackgroundDRB
AP4R
Background jobs in ruby on rails
scheduling tasks in ruby on rails

No comments: