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.

damd
  • 6,116
  • 7
  • 48
  • 77

2 Answers2

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)
aaron
  • 6,339
  • 12
  • 54
  • 80
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

Ben Boyer
  • 1,234
  • 9
  • 14