“Whenever” gem running cron jobs on Heroku

后端 未结 3 2070
情话喂你
情话喂你 2020-12-04 19:35

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

3条回答
  •  半阙折子戏
    2020-12-04 19:51

    You need to add Heroku Scheduler addon.

    You can add it directly from your dashboard or using following commands:

    1. install the add-on:

      heroku addons:create scheduler:standard
      
    2. Create a rake task in lib/tasks

      # lib/tasks/scheduler.rake
      task :send_reminders => :environment do
        User.send_reminders
      end
      
    3. Schedule job

      • Visit Heroku Dashboard
      • Open your app
      • Select Scheduler from add-ons list
      • Click 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.

提交回复
热议问题