Heroku Rake/Cron - No Namespace
19 Nov 2010Tags: heroku ruby on rails cron error
So, if you are making a cron job for Heroku and you have gone ahead and make a cron.rake file in lib/tasks, you also need to remove the “namespace :cron do … end” code from any example code you may have used as a start.
Heroku only executes the “rake cron” command when your task runs, instead of “rake cron:cron”, so if you have the namespace in your rake file, it’ll fail with a “rake aborted! Don’t know how to build task ‘cron’” error.
In short, do this:
namespace :cron do desc “cron job description” task **:blah** => :environment do # stuff to do end end
Instead of this:
desc “cron job description” task **:cron** => :environment do # stuff to do end