Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 定期(每天一次)运行Django函数时使用什么工具/应用程序?_Python_Django - Fatal编程技术网

Python 定期(每天一次)运行Django函数时使用什么工具/应用程序?

Python 定期(每天一次)运行Django函数时使用什么工具/应用程序?,python,django,Python,Django,你能为Django 2.2推荐一个定期运行函数的应用程序或工具吗?我有一份产品清单,希望每天更新一次价格。我听说过芹菜,但也许有更简单的东西我可以用?提前感谢。使用相对简单 如果您根本不想使用芹菜,您可以编写一个脚本,并通过cron作业定期调用它 你可以用芹菜 from celery.schedules import crontab CELERY_BEAT_SCHEDULE = { "update-task-on-mathmod.org": { "task": "project.app

你能为Django 2.2推荐一个定期运行函数的应用程序或工具吗?我有一份产品清单,希望每天更新一次价格。我听说过芹菜,但也许有更简单的东西我可以用?提前感谢。

使用相对简单

如果您根本不想使用芹菜,您可以编写一个脚本,并通过cron作业定期调用它

你可以用芹菜

from celery.schedules import crontab

CELERY_BEAT_SCHEDULE = {
"update-task-on-mathmod.org": {
    "task": "project.app1.tasks.task_that_run_daily",
    "schedule": crontab(minute=0, hour=0),  # execute daily at midnight

}
}
和在任务文件中

@shared_task()
def task_that_run_daily():
    print(".......running once a day.......")