Reputation: 52797
There's a straight forward explanation of why cron jobs and tasked scheduled with whenever gem won't work on heroku
Is there any way to schedule a rake task to run more frequently than every 10 minutes (the minimum frequency heroku scheduler offers), for example every 1 minute?
Upvotes: 0
Views: 819
Reputation: 52797
I think @ollaollu's method is probably superior, but for future reference what worked for me was to use a Procfile
to run an infinite loop on boot, and that effectively runs a process every 5 seconds and even works after heroku restart
.
Upvotes: 0
Reputation: 483
You can use a combination of Clockwork gem and Heroku Procfile.
lib/clock.rb
, you can do something like:every(1.minute, 'Run task') do
Rake::Task['namespace:task'].invoke
end
clock: bundle exec clockwork lib/clock.rb
to your Heroku ProcfileClockwork supports a lot of time variations.
Upvotes: 1