Reputation: 2189
I want to automatically send a list of orders to all my suppliers from monday to friday at 11:00am. How can I do that ?
I am using Rails 5.1
I know that ActiveJobs has the Notifier.deliver_later function but if I'm right, it only works with relative times (eg: 10 hours from now). I actually need emails to be sent at 11:00 precise.
Upvotes: 0
Views: 355
Reputation: 3722
I'd suggest you use Sidekiq with Sidekiq-cron this gem can work on high loaded projects, has Sidekiq UI (from Sidekiq), you can observe and relaunch jobs by your self from Sidekiq UI side.
Sidekiq more flexible and more useful can works with concurrency, has queues with privileges etc. (all advantages of Sidekiq)
Upvotes: 1
Reputation: 651
You can use whenever gem for this task. It provides a clear syntax for writing and deploying cron jobs.
Install this gem or add in gemfile. Go to your project directory and run whenevrize .
.
$ cd /apps/my-great-project
$ wheneverize .
It creates a config/schedule.rb
file in your project. Now you can add your task in this file and the gem will take care of everything.
For your case it'll look something like this.
every :weekday, at: '11:00 am' do
runner "MyModel.task_to_run_at_eleven_in_the_morning_on_weekdays"
end
Upvotes: 2