简体   繁体   English

在部署在heroku上的Django应用中运行计划的作业

[英]running scheduled job in django app deployed on heroku

I have deployed a django app on heroku. 我已经在heroku上部署了django应用。 So far it works fine. 到目前为止,它工作正常。 Now I have to schedule a task (its in the form of python script) once a day. 现在,我必须每天安排一次任务(以python脚本的形式)。 The job would take the data from heroku database perform some calculations and post the results back in the database. 作业将从heroku数据库中获取数据以执行一些计算,然后将结果重新发布到数据库中。 I have looked at some solutions for this usually they are using rails in heroku. 我已经看过一些解决方案,通常他们在heroku中使用rails。 I am confused whether I should do it using the cron jobs extension available in django or using the scheduled jobs option in heroku. 我是否应该使用django中提供的cron作业扩展名或使用heroku中的计划作业选项来做这件事感到困惑。 Since the application is using using heroku I thought of using that only but I dont get any help how to add python jobs in it. 由于该应用程序正在使用heroku,因此我想到了仅使用它,但是在如何添加python作业方面我没有任何帮助。 Kindly help. 请帮助。

I suggest you to create a Django management command for your project like python mananage.py run_this_once_a_day . 我建议您为项目创建Django管理命令,例如python mananage.py run_this_once_a_day And you can use Heroku schedular to trigger this scheduling. 您可以使用Heroku计划表来触发此计划。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM