Search code examples
ruby-on-rails-3scheduled-tasksredisresque

How to destroy jobs enqueued by resque workers?


I'm using Resque on a rails-3 project to handle jobs that are scheduled to run every 5 minutes. I recently did something that snowballed the creation of these jobs and the stack has hit over 1000 jobs. I fixed the issue that caused that many jobs to be queued and now the problem I have is that the jobs created by the bug are still there and therefore It becomes difficult to test something since a job is added to a queue with 1000+ jobs. I can't seem to stop these jobs. I have tried removing the queue from the redis-cli using the flushall command but it didn't work. Am I missing something? coz I can't seem to find a way of getting rid of these jobs.


Solution

  • If you pop open a rails console, you can run this code to clear out your queue(s):

    queue_name = "my_queue"
    Resque.redis.del "queue:#{queue_name}"