【发布时间】:2021-03-23 17:53:58
【问题描述】:
问候各位程序员, 我目前正在使用 django-background-tasks(https://django-background-tasks.readthedocs.io/en/latest/) 在 AWS elasticbeanstalk 上运行一些后台任务。我最初在主 .config 容器命令中使用此命令,但在部署中出现超时错误,因为此管理命令永远不会完成(它会继续运行)。 现在,我正在尝试使用建议的方法在 elasticbeanstalk(https://aws.amazon.com/premiumsupport/knowledge-center/cron-job-elastic-beanstalk/) 上运行 cron 作业。请看一下我的代码,它没有运行命令。请问有什么问题?我只需要命令 python manage.py process_tasks 继续运行。这在我的本地机器上正常工作,因为我可以轻松打开另一个终端来启动 python manage.py process_tasks 命令
files:
"/etc/cron.d/process_tasks_cron":
mode: "000644"
owner: root
group: root
content: |
* * * * * root /usr/local/bin/99_process_tasks.sh
"/usr/local/bin/99_process_tasks.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
date > /tmp/date
# Your actual script content
source /var/app/venv/*/bin/activate
python manage.py process_tasks
commands:
remove_old_cron:
command: "rm -f /etc/cron.d/*.bak"
【问题讨论】:
标签: python django amazon-web-services cron amazon-elastic-beanstalk