Skip to content

Instantly share code, notes, and snippets.

@chhantyal
Created September 13, 2013 07:35
Show Gist options
  • Save chhantyal/6547720 to your computer and use it in GitHub Desktop.
Save chhantyal/6547720 to your computer and use it in GitHub Desktop.
Periodic tasks with celery
from celery.task.schedules import crontab
from celery.decorators import periodic_task
from .models import send_all
# Every ten minutes
@periodic_task(run_every=crontab(hour="*", minute="*/10", day_of_week="*"))
def send_newsletter():
print("Sending Newsletters")
send_all()
# Every minute
@periodic_task(run_every=crontab(hour="*", minute="*", day_of_week="*"))
def every_minute():
print("Every minute, I am called :(")
# Every minute
@periodic_task(run_every=crontab(minute="*/1"))
def hello_world():
print("Hello world")
@harry91
Copy link

harry91 commented Jul 22, 2018

celery.decorators will be removed in Celery 5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment