Celery Crontab 没有选择任务
Celery Crontab in not Picking the tasks
我在 celery 节拍时间表中每 1 分钟添加一次 crontab。迁移也正确完成。我可以在这段代码中遗漏任何内容吗?crontab 格式是否正确。
提前致谢 。几分钟的 crontab 将工作
settings.py
INSTALLED_APPS = [
'app1',
'django_celery_beat',
]
CELERY_BROKER_URL = 'amqp://localhost'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TASK_SERIALIZER = 'json'
from celery.schedules import crontab
CELERY_BEAT_SCHEDULE = {
'task-second': {
'task': 'app1.tasks.elast',
'schedule': crontab(minute=1),
}
}
celery.py
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proj.settings')
app = Celery('proj')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()
__init__.py
from __future__ import absolute_import, unicode_literals
from .celery import app as celery_app
__all__ = ('celery_app',)
tasks.py
from __future__ import absolute_import, unicode_literals
from proj.celery import app
@app.task
def elast():
print("start")
return "Exceuting after 1 minute"
celery beat worker:
celery -A proj beat --loglevel=debug --scheduler django_celery_beat.schedulers:DatabaseScheduler
logformat :
celery beat v5.1.2 (sun-harmonics) is starting.
[2021-07-27 11:07:00,894: DEBUG/MainProcess] beat: Ticking with max interval->5.00 seconds
[2021-07-27 11:07:00,916: DEBUG/MainProcess] beat: Waking up in 5.00 seconds.
[2021-07-27 11:07:05,931: DEBUG/MainProcess] beat: Synchronizing schedule...
[2021-07-27 11:07:05,932: DEBUG/MainProcess] Writing entries...
改变
*'schedule': crontab(minute=1),*
进入
'schedule': crontab(minute='*/1'),
应该可以。
我在 celery 节拍时间表中每 1 分钟添加一次 crontab。迁移也正确完成。我可以在这段代码中遗漏任何内容吗?crontab 格式是否正确。
提前致谢 。几分钟的 crontab 将工作
settings.py
INSTALLED_APPS = [
'app1',
'django_celery_beat',
]
CELERY_BROKER_URL = 'amqp://localhost'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TASK_SERIALIZER = 'json'
from celery.schedules import crontab
CELERY_BEAT_SCHEDULE = {
'task-second': {
'task': 'app1.tasks.elast',
'schedule': crontab(minute=1),
}
}
celery.py
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proj.settings')
app = Celery('proj')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()
__init__.py
from __future__ import absolute_import, unicode_literals
from .celery import app as celery_app
__all__ = ('celery_app',)
tasks.py
from __future__ import absolute_import, unicode_literals
from proj.celery import app
@app.task
def elast():
print("start")
return "Exceuting after 1 minute"
celery beat worker:
celery -A proj beat --loglevel=debug --scheduler django_celery_beat.schedulers:DatabaseScheduler
logformat :
celery beat v5.1.2 (sun-harmonics) is starting.
[2021-07-27 11:07:00,894: DEBUG/MainProcess] beat: Ticking with max interval->5.00 seconds
[2021-07-27 11:07:00,916: DEBUG/MainProcess] beat: Waking up in 5.00 seconds.
[2021-07-27 11:07:05,931: DEBUG/MainProcess] beat: Synchronizing schedule...
[2021-07-27 11:07:05,932: DEBUG/MainProcess] Writing entries...
改变
*'schedule': crontab(minute=1),*
进入
'schedule': crontab(minute='*/1'),
应该可以。