I created an app that uses the whenever gem. The gem creates cron jobs. I got it working locally but can\'t seem to get it working on heroku cedar. What\'s the command to do
If you want to:
Heroku Scheduler
This was my solution hack to run jobs every minute - assuming the task completes in under 60 seconds.
task start_my_service: :environment do
1.upto(9) do |iteration|
start_time = DateTime.now
Services::MyService.call
end_time = DateTime.now
wait_time = 60 - ((end_time - start_time) * 24 * 60 * 60).to_i
sleep wait_time if wait_time > 0
end
end
You need to add Heroku Scheduler addon.
You can add it directly from your dashboard or using following commands:
install the add-on
:
heroku addons:create scheduler:standard
Create a rake task in lib/tasks
# lib/tasks/scheduler.rake
task :send_reminders => :environment do
User.send_reminders
end
Schedule job
add-ons
listClick Add Job, enter a task and select frequency.
e.g. Add rake send_reminders
, select "Daily"
and "00:00"
to send reminders every day at midnight.
Short answer: use the scheduler add-on: http://addons.heroku.com/scheduler
Long answer: When you do heroku run, we
Any changes you made to crontab would be immediately thrown away. Everything is ephemeral, you cannot edit files on heroku, just push new code.