如何在 rails 中每五分钟调用一次 sidekiq 执行函数

How to call sidekiq perform fuction after every five minutes in rails

require 'sidekiq'

module KYC
  module VerifyInvestor
    class AccreditedVerificationWorker
      include Sidekiq::Worker
       
      def perform()
        ....
      end
    end
  end
end

对于免费解决方案,您可以使用 sidekiq-cron gem 并每 5 分钟创建一个从控制台到 运行 的 cron 作业:

Sidekiq::Cron::Job.create(name: 'AccreditedVerificationWorker - every 5min', cron: '*/5 * * * *', class: 'KYC::VerifyInvestor::AccreditedVerificationWorker')