A quick script to selectively remove Failed Jobs from Resque 1.x
Copy to snippet below and paste it in a rails console
def delete_if
redis = Resque.redis
(0...Resque::Failure.count).each do |i|
string = redis.lindex(:failed, i)
break if string.nil?
job = Resque.decode(string)
remove = yield job
next unless remove
redis.lrem(:failed, 1, string)
redo
end
end
To selectively delete a subset of failed jobs, say delete all push notification jobs that have failed because of http errors
delete_if do |job|
job['payload']['class'] == 'SendPushNotification' &&
job['exception'] == 'Pusher::HTTPError'
end
Here's a gist for the same https://gist.github.com/nisanth074/11332107
Written by Nisanth
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Related Tags
#rails
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#