django-orchestra-test/orchestra/contrib/orchestration/tasks.py
2015-05-05 19:42:55 +00:00

16 lines
437 B
Python

from datetime import timedelta
from celery.task.schedules import crontab
from django.utils import timezone
from orchestra.contrib.tasks import periodic_task
from .models import BackendLog
@periodic_task(run_every=crontab(hour=7, minute=0))
def backend_logs_cleanup():
days = settings.ORCHESTRATION_BACKEND_CLEANUP_DAYS
epoch = timezone.now()-timedelta(days=days)
BackendLog.objects.filter(created_at__lt=epoch).delete()