Not sure if I am doing this right. Reading: http://devcenter.heroku.com/articles/cron#frequently-asked-questions
If I have cron running every 24 hours on Heroku. Will it run def foo and def bar every 24 hours? Or should I wrap both methods with if Time.now.hour % 24== 0 # run every 24 hours?
desc "This task is called by the Heroku cron add-on"
task :cron => :environment do
def foo
puts 'foo'
end
deb bar
puts 'bar'
end
end
Second, how can I run this cron job on my local machine (possibly via console or other method)?
PS. I am running Rails 3.1 RC5 on the Cedar stack.
If you’ve set up the cron as “daily” then it will run every 24 hours, there’s no need to put an if statement in there.
To run the cron task locally just do
rake cronEdit:
You’ll also need to call the methods you’ve defined in there as currently all your cron does is define foo and bar: