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.
7 Answers
Playing off of the above answers, if you need to clear all of your queues, you could use the following:
Resque.queues.each{|q| Resque.redis.del "queue:#{q}" }

- 4,198
- 4
- 33
- 42
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}"

- 10,725
- 3
- 39
- 46

- 123,080
- 26
- 284
- 201
-
4As found in @denmarkin's answer below, use Resque.redis.del instead of Resque.redis.delete – James P McGrath Nov 03 '11 at 04:08
Resque already has a method for doing this - try Resque.remove_queue(queue_name)
(see the documentation here). Internally it performs Resque.redis.del()
, but it also does other cleanup, and by using an api method (rather than making assumptions about how resque works) you'll be more future-proof.

- 436
- 3
- 8

- 1,851
- 1
- 21
- 20
This is what works now:
Resque.remove_queue("...")

- 4,333
- 2
- 43
- 58
-
Yep, that seems to be the right way to do this: http://www.rubydoc.info/gems/resque/1.27.4/Resque#remove_queue-instance_method – jwadsack Oct 27 '17 at 16:10
Updated rake task for clearing (according to latest redis commands changes): https://gist.github.com/1228863

- 233
- 3
- 10
It's safer and bulletproof to use the Resque API rather than deleting everything on the Resque's Redis. Resque does some cleaning in the inside.
If you want to remove all queues and associated enqueued jobs:
Resque.queues.each {|queue| Resque.remove_queue(queue)}
The queues will be re-created the next time a job is enqueued.

- 9,555
- 4
- 35
- 63
Enter redis console:
redis-cli
List databases:
127.0.0.1:6379> KEYS *
1) "resque:schedules_changed"
2) "resque:workers"
3) "resque:queue:your_overloaded_queue"
"resque:queue:your_overloaded_queue"
- db which you need.
Then run:
DEL resque:queue:your_overloaded_queue
Or if you want to delete specified jobs in queue then list few values from db with LRANGE
command:
127.0.0.1:6379> LRANGE resque:queue:your_overloaded_queue 0 2
1) "{\"class\":\"AppClass\",\"args\":[]}"
2) "{\"class\":\"AppClass\",\"args\":[]}"
3) "{\"class\":\"AppClass\",\"args\":[]}"
Then copy/paste one value to LREM
command:
127.0.0.1:6379> LREM resque:queue:your_overloaded_queue 5 "{\"class\":\"AppClass\",\"args\":[]}"
(integer) 5
Where 5 - number of elements to remove.

- 5,198
- 5
- 40
- 44
-
1Redis recommends that you [not run `KEYS *` on a production database](https://redis.io/commands/keys) as it scans the entire set of keys and locks all records. This could adversely affect your background workers on a very busy system. – jwadsack Nov 14 '17 at 04:48