Hello, until now I allways used script/runner for running Rails cron jobs I wonder is there is any benefit (except not having any fake runner model in the models directory) to use a rake task instead in lib/tasks Thanks
on 2008-10-22 11:55
on 2008-10-22 15:18
Christophe G. wrote: > Hello, until now I allways used script/runner for running Rails cron > jobs Hi, I also want to use the script/runner to run the Rails cron jobs. But I don't know how to do that. So can you please share the code here so that i will get some ideas? Thanks in advance...
on 2008-10-23 09:56
It's very simple, all you have to do is create a new model in app/models, eg. runner.rb class Runner def self.doIt() end end Then, launch it from the command line script/runner Runner.doIt or a cron task ruby /somedir/script/runner Runner.doIt
on 2011-12-18 16:38
The difference between them is that script/runner boots Rails whereas a Rake task doesn't unless you tell it to by making the task depend on :environment, like this: task :some_useful_task => :environment do # do some useful task end Since booting Rails is expensive, it might be worth skipping if you can avoid it. Other than that, they are roughly equivalent.