Skip to content
Recurring / Periodic / Scheduled / Cron job extension for Sidekiq
Branch: master
Clone or download
Latest commit 33c70c7 Apr 1, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets exclude pngs from gem Dec 24, 2015
lib bump gem version Apr 1, 2019
test test tweaks Apr 1, 2019
web/views update readme Dec 24, 2015
.gitignore initial Dec 23, 2015
.travis.yml remove sidekiq=stable from travis Feb 21, 2019
Gemfile remove sidekiq=stable from travis Feb 21, 2019
LICENSE.txt initial Dec 23, 2015 Minor update to readme to avoid confusion Feb 25, 2019
Rakefile Make work with ActiveJob Feb 5, 2017
sidecloq.gemspec redlock released 1.0 Feb 3, 2019



Build Status Gem Version Code Climate Test Coverage Dependency Status

Recurring / Periodic / Scheduled / Cron job extension for Sidekiq


There are several options for running periodic tasks with Sidekiq, including sidekiq-scheduler, sidekiq-cron, as well as Sidekiq Enterprise. Each tackles the problem slightly differently. Sidecloq is inspired by various facets of these projects, as well as resque-scheduler. I urge you to take a look at all of these options to see what works best for you.

Sidecloq is:

  • Lightweight: Celluloid is not required. This coincides well with Sidekiq 4/5, which no longer use Celluloid.
  • Clean: Sidecloq leverages only the public API of Sidekiq, and does not pollute the Sidekiq namespace.
  • Easy to deploy: Sidecloq boots with all Sidekiq processes, automatically. Leader election ensures only one process enqueues jobs, and a new leader is automatically chosen should the current leader die.
  • Easy to configure: Schedule configuration is done in YAML, using the familiar cron syntax. No special DSL or job class mixins required.


Add this line to your application's Gemfile:

gem 'sidecloq'

Tested on MRI > 2 and JRuby 9k. Basically, if you can run Sidekiq, you can run Sidecloq. Note that Sidekiq >= 5 does not support MRI ruby < 2.2.2.



Tell Sidecloq where your schedule file is located:

Sidecloq.configure do |config|
  config[:schedule_file] = "path/to/myschedule.yml"


If using Rails, and your schedule is located at config/sidecloq.yml, Sidecloq will find the schedule automatically (ie, you don't have to use the above configuration block).

Schedule file format


my_scheduled_job: # a unique name for this schedule
  class: Jobs::DoWork # the job class
  args: [100]       # (optional) set of arguments
  cron: "* * * * *" # cron formatted schedule
  queue: "queue_name" # Sidekiq queue for job

  class: Jobs::WorkerWithArgs
    batch_size: 100
  cron: "1 1 * * *"
  queue: "queue_name"

  class: Jobs::AnotherClassName
  cron: "1 1 * * *"
  queue: "a_different_queue"


If using Rails, you can nest the schedules under top-level environment keys, and Sidecloq will select the correct group based on the Rails environment. This is useful for development/staging scenarios. For example:

  # these will only run in production
    class: Jobs::ClassName
    cron: "* * * * *"
    queue: "queue_name"

  # this will only run in staging
    class: Jobs::AnotherClassName
    cron: "1 1 * * *"
    queue: "a_different_queue"

Web Extension

Add Sidecloq::Web after Sidekiq::Web:

require 'sidekiq/web'
require 'sidecloq/web'

This will add a "Recurring" tab to the sidekiq web ui, where the loaded schedules are displayed. You can enqueue a job immediately by clicking it's corresponding "Enqueue now" button.

Sidecloq web ui extension screenshot


If you are running MRI < 2.2.2, you will need to make sure you are using rack < 2.0. You can do this by adding:

gem 'rack', '< 2.0'

To your app's Gemfile. (This will also keep you from using the 5.x series of Sidekiq, as it requires MRI > 2.2.2).


Bug reports and pull requests are welcome.


The gem is available as open source under the terms of the MIT License.

You can’t perform that action at this time.