![](/img/trans.png)
[英]If i have to run cron job every Friday at 10am, is this the rite setting: 0 17 5 * * *
[英]Django Huey Crontab every day at 10am
我正在使用 Django 4.0.4 和 Huey 2.4.3。 我想要實現的是每天上午 10 點運行一個任務,使用周期性任務。
為此,您可以通過pip install django-celery
使用並使用 celery。
from celery.schedules import crontab
from celery.task import periodic_task
@periodic_task(run_every=crontab(hour=10, minute=0))
def every_day():
print("This is run every Monday morning at 10:00")
既然您提到您正在使用huey
包作為代碼的一部分。 您可以利用它的periodic_task
裝飾器並在其中添加crontab。
from huey import crontab
@huey.periodic_task(crontab(hour='10'))
def every_ten_in_the_morning():
print('This task runs every 10 in the morning.')
您還可以查看其文檔以了解有關休伊定期任務的更多信息:https ://huey.readthedocs.io/en/latest/guide.html#periodic-tasks
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.