A brief introduction: Today to talk celery timing tasking capabilities
Two standard processes:
1 configuration config.py
from celery.schedules import crontab
CELERYBEAT_SCHEDULE = {
' celery_test.tasks.test_run': {
'task': 'celery_test.tasks.test_run',
'schedule': crontab(minute='*/2')
}
}
2 Start woker process
3 to start the process of crontab
celery -A celery_demo.celery beat -l info -f log
4 View log information
[2019-09-12 10:38:00,011: INFO/MainProcess] Scheduler: Sending due task celery_test.tasks.test_run (celery_test.tasks.test_run)
[2019-09-12 10:38:00,036: DEBUG/MainProcess] celery_test.tasks.test_run sent. id->d16b6bd8-15c6-4d65-b46d-a215602776c0
5 crontab settings
参数 minute hour day_of_week
Examples of 'schedule': crontab (minute = 0, hour = 8, day_of_week = [1, 2, 3, 4, 5]) 1-5 week 8 am performed