Rails - Whenever gem - Dynamic values

后端 未结 4 1806
Happy的楠姐
Happy的楠姐 2020-12-05 21:08

Lets say I have a cronjob like this:

every 1.day, :at => \'4:30 am\' do  
  runner \"MyModel.task_to_run_at_four_thirty_in_the_morning\"  
end  
         


        
4条回答
  •  一个人的身影
    2020-12-05 21:37

    I had the same task and decided to solve it a bit another approach. In my table have a lot of records where storing settings for schedule (daily, monthly, weekly, time)

    In schedule.rb file I added a cron job, which was running every day at 00:00 and select the records, which can be run today. And after it added to queue with sidekiq using perform_at.

提交回复
热议问题