Search code examples
ruby-on-railsrubycronschedulersidekiq

Schedule Job each 10 seconds - ruby


I need a scheduler mechanism that will run each 10 seconds. I use sidekiq, and that's why i wanted to use sidekiq-cron, but the smallest time unit is one minute. Moreover, I need only one job instance running at a time.

What is the best practice for this situation?

By the way, we are using Rails 4.2, Ruby 2.1.2, Unicorn as web server and Sidekiq 3.

Thanks

EDIT: I need it to run every 10 seconds


Solution

  • Sidekiq has scheduling methods: https://github.com/mperham/sidekiq/wiki/Scheduled-Jobs

    So you can do

    MyWorker.perform_in(10.seconds)