Greetings fellow programmers, I am currently using django-background-tasks( https://django-background-tasks.readthedocs.io/en/latest/ ) to run some background tasks on AWS elasticbeanstalk. I initially use this command in the main.config container commands but I get timeout error in deployment because this management command will never finish(it continues to run on). Now, I am trying using the approach suggested for running cron job on elasticbeanstalk( https://aws.amazon.com/premiumsupport/knowledge-center/cron-job-elastic-beanstalk/ ). Please take a look at my code, it is not running the command. what is wrong pls? I just need the command python manage.py process_tasks to keep running on. This is working properly on my local machine since i can easily open another terminal to fire up the python manage.py process_tasks command
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"
this a working version of the code. thanks and hope it helps someone out there.
files:
"/etc/cron.d/cron_process":
mode: "000644"
owner: root
group: root
content: |
* * * * * root /usr/local/bin/task_process.sh
"/usr/local/bin/task_process.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
exec &>> /tmp/cron_capture_log.txt
date > /tmp/date
source /var/app/venv/staging-LQM1lest/bin/activate
cd /var/app/current
python manage.py process_tasks
commands:
remove_old_cron:
command: "rm -f /etc/cron.d/cron_process.bak"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.