views:

107

answers:

1

I have setup my schedule.rb file as follows.

set :cron_log, "/log/cron_log.log"
if Rails.env.development?
  every 1.minute do
    runner "SomeModel.move_values"
    runner "SomeOtherModel.dispense"
   end
end

I also make it work in development mode by whenever --update-crontab trunk --set environment=development

But my model methods (class methods) are never called. Is there some way I can verify if its configured right. when I simply use update it resets the settings to use the production environment.

A: 

Hi Sid I just got done using that same javan-whenever plugin.

In your rails project, type crontab -l. If you see the crontab properly generated then you know it's either the code or some server thing.

You may want to consider doing set :environment, RAILS_ENV in your schedule.rb file to set the environment dynamically.

Ryan Bates has done a good screencast on this: http://railscasts.com/episodes/164-cron-in-ruby

Also, after I got done implementing this I also found this site: webbasedcron it looks much easier than javan-whenever.

tybro0103
Sid
Just to be sure, the crontab you just posted is from your production server correct? If not, it should say "-e development". Another check, if you open the console and run "CreditDetail.move_values" or "Exp.dispense" are any errors thrown?
tybro0103
No i want to run the cron on my development machine. And thanks for the answer. I realized that the version of the gem i was using was dated and the one available on gemcutter is the newest version of the gem. I got it running once i got the gem from the new source.Thank you.
Sid
oh cool.. just be sure to set the environment to dev since it defaults to production.. :)
tybro0103