#正常启动
python3.7 manage.py celery worker -A MxOnline --loglevel=info
# debug 启动
python3.7 manage.py celery worker -A MxOnline -l debug
# 监控定是脚本
python3.7 manage.py celery beat --loglevel=info
定时任务添加方法:
项目下 celery.py
from celery.schedules import crontab
app.conf.update(
CELERYBEAT_SCHEDULE = {
'sum-task': {
'task': 'deploy.tasks.add',
'schedule': timedelta(seconds=20),
'args': (5, 6)
}
'send-report': {
'task': 'deploy.tasks.report',
'schedule': crontab(hour=4, minute=30, day_of_week=1),
}
}
)
django 下执行 定时执行
安装 django_celery_beat
celery -A MxOnline beat -l info -S django