Schedule background task with Sidekiq

cron, ruby-on-rails-3, sidekiq

Solution

You might want to have a look at `sidetiq` too. https://github.com/tobiassvn/sidetiq The gem supports complex timing expressions via the `ice_cube` gem.

I personally found comfortable to have a gem that would integrate seemlessly with sidekiq.

Something like that should work:

class TaskWorker
  include Sidekiq::Worker
  include Sidetiq::Schedulable

  recurrence do
    daily.hour_of_day(0).minute_of_hour(1)
  end

  def perform
    # do magic
  end
end

Careful though when using this gem since there are some performance related issues with some time expressions. https://github.com/tobiassvn/sidetiq/wiki/Known-Issues. The expression I gave you should circumvent this issue though.

Problem

I have a Rails 3 app deployed heroku. I have a Sidekiq worker at `app/workers/task_worker.rb`: ``` class TaskWorker include Sidekiq::Worker def perform ... end end ``` How to schedule execution of `TaskWorker.perform_async` daily at 12:01 a.m?

Original source

Related problems