Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fetch Resque jobs scheduled with resque-scheduler

I'm working on a rails app that uses resque and resque-scheduler to schedule email sending.

Is there a way to get a list of all the scheduled jobs, or even better a list of jobs that have a specific argument?

I've tried a few things like Resque.schedule but the best I can get is this hash:

{"send_email"=>
  {
    "class"=>"EmailSendingJob",
    "args"=>nil,
    "queue"=>"email_queue",
    "description"=>"Runs the perform method in EmailSendingJob"
  }
}
like image 467
jovana Avatar asked Jun 30 '15 12:06

jovana


1 Answers

I actually needed a list of all the delayed jobs, which are one time jobs that will be put in the queue at some time in the future, whereas the scheduled jobs are recurring on a regular basis.

find_delayed_selection method is exactly what I needed, it allows finding of delayed jobs that have arguments matching certain criteria. This method is not available in the current stable release of resque-scheduler 4.0.0, so I ended up using the master branch.

Here is the link to the pull request where the method was added https://github.com/resque/resque-scheduler/pull/452

like image 123
jovana Avatar answered Sep 30 '22 18:09

jovana