如何安排任务在特定时间使用芹菜进行?

编程入门 行业动态 更新时间:2024-10-09 01:23:53
本文介绍了如何安排任务在特定时间使用芹菜进行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经研究了 PeriodicTask ,但是这些例子只包括使其重复出现。我正在寻找一些更像codecron 的能力,说每个星期一凌晨1点执行这个任务的一些东西。

I've looked into PeriodicTask, but the examples only cover making it recur. I'm looking for something more like cron's ability to say "execute this task every Monday at 1 a.m."

推荐答案

最近发布的版本1.0.3现在支持这一点,谢谢Patrick Altman!

The recently released version 1.0.3 supports this now, thanks to Patrick Altman!

示例:

from celery.task.schedules import crontab from celery.decorators import periodic_task @periodic_task(run_every=crontab(hour=7, minute=30, day_of_week="mon")) def every_monday_morning(): print("This runs every Monday morning at 7:30a.m.")

有关更多信息,请参阅更改日志:

See the changelog for more information:

celeryproject/docs/changelog.html

更多推荐

如何安排任务在特定时间使用芹菜进行?

本文发布于:2023-11-27 14:27:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638451.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:芹菜   时间   在特定

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!