Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Sidekiq allows you to schedule the time when a job will be executed. You use
perform_in(interval, *args) or
perform_at(timestamp, *args) rather than the standard
MyWorker.perform_in(3.hours, 'mike', 1) MyWorker.perform_at(3.hours.from_now, 'mike', 1)
This is useful for example if you want to send the user an email 3 hours after they sign up. Jobs which are scheduled in the past are enqueued for immediate execution.
Sidekiq's scheduling is time zone independent. Sidekiq calls
.to_f on the timestamp argument, which avoids time zone confusion. See this issue for more details.
Checking for New Jobs
Sidekiq's scheduler is not meant to be second-precise. It checks for scheduled jobs approximately every 5 seconds by default (15 seconds before Sidekiq 5.1). You can adjust this interval:
Sidekiq.configure_server do |config| config.average_scheduled_poll_interval = 15 end
Sidekiq Enterprise supports periodic jobs. Other 3rd party gems also offer cron-like functionality.