title: Sidekiq With Whenever
body: <p>I'm using whenever for schedule of job with sidekiq. Also, use <code>sidekiq-client-cli</code> gem, that is a command line client for sidekiq and allows the cron jobs to interact with sidekiq.</p>
  
  <p>This my active job file :</p>
  
  <pre><code># jobs/clone_record_job.rb
  
  class CloneRecordJob &lt; ActiveJob::Base
      queue_as :myapps
  
      def perform(*args)
        Core::Block.where(release_date: Date.today - 30.days).each do |block|
          new_block = Core::Block.new(block.attributes)
          new_block._id = BSON::ObjectId.new
          new_block.save
        end
      end
  end
  </code></pre>
  
  <p>schedule file :</p>
  
  <pre><code># config/schedule.rb
  job_type :sidekiq, "cd :path &amp;&amp; :environment_variable=:environment bundle exec sidekiq-client -q myapps push :task :output"
  
  every 1.minute, :roles =&gt; [:app] do
      sidekiq "CloneRecordJob"
  end
  </code></pre>
  
  <p>Sidekiq log :</p>
  
  <pre><code>2016-08-09T10:13:41.138Z 23668 TID-xvshg WARN: {"class":"CloneRecordJob","queue":"myapps","args":[],"retry":true,"jid":"98cb26a0dd7410a9be0f0200","created_at":1470737621.1380692,"enqueued_at":1470737621.1382036}
  2016-08-09T10:13:41.141Z 23668 TID-xvshg WARN: NoMethodError: undefined method `jid=' for #&lt;CloneRecordJob:0x0000000715cc30&gt;
  </code></pre>
  
  <p>Note :</p>
  
  <p>I'm sure that job is work when to call from controller.</p>
  
  <pre><code># example method
  def my_action
    CloneRecordJob.perform_now
  end
  </code></pre>