Setup Scheduled Jobs with Sidekiq, Redis & Ruby on Rails

Sidekiq has been my favorite tool for setting up background processing in Ruby on Rails applications. Mainly I use it for delivering emails, update data inside tables & much more… and it can take a little effort to get up and running every day in exact time on i.e. Heroku.

I have worked with Heroku Scheduler jobs but I have found some issues which explained there documentation that’s why I’m using Sidekiq Scheduler.

Follow below steps:


gem install sidekiq-scheduler

or you can use your Gemfile
# sidekiq
gem 'sidekiq', '~> 3.3.0'
# sidekiq scheduler
gem 'sidekiq-scheduler', '~> 1'

Then create a folder inside app directory which name “workers”.


Create a file inside workers folder like “hello_world.rb”.

class HelloWorld
  include Sidekiq::worker
  def perform #=> you can write anything based on your action like 'send_email' or 'newslatter' etc ...
     puts 'Hello World'

Now you can go your config file config/sidekiq.yml

  every: 1m   # Runs once per minute
  class: HelloWorld

Then run

bundle exec sidekiq

Redis is required for sidekiq, install this on your Heroku app then past this on your Procfile same as below-

worker: bundle exec sidekiq -c 5 -v

Then push to your production.

Happy coding 🙂