3

Is there any way in Celery to remove all previous task results via command line? Everything I can find references purge, but that doesn't seem to be for task results. Other solutions I have found include using a Celery beat which periodically removes it, but I'm looking for a one-off command line solution.

I use Celery 4.3.0.

2 Answers 2

3

Here's what you're looking for I think:

https://github.com/celery/celery/issues/4656

referencing

https://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-result_expires

I set this up as follows:

RESULT_EXPIRE_TIME = 60 * 60 * 4 # keep tasks around for four hours ... celery = celery.Celery('tasks', broker=Config.BROKER_URL, backend=Config.CELERY_RESULTS_BACKEND, include=['tasks.definitions'], result_expires=RESULT_EXPIRE_TIME) 
Sign up to request clarification or add additional context in comments.

Comments

0

So based on this answer: How do I delete everything in Redis?

With redis-cli:

FLUSHDB - Removes data from your connection's CURRENT database. FLUSHALL - Removes data from ALL databases. 

Redis documentation:

flushdb flushall 

For example, in your shell:

redis-cli flushall

and try to purge celery as well. From celery doc: http://docs.celeryproject.org/en/latest/faq.html?highlight=purge#how-do-i-purge-all-waiting-tasks

1 Comment

This will delete everything like it says, bad advice. The OP only wants to delete task results.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.