I am running a small Django web application on Elastic Beanstalk. It uses django-background-tasks to run some asynchronous tasks. This works locally since I can run python manage.py process_tasksto complete tasks.
However, I had a bit more trouble getting this to work as desired after deploying to Elastic Beanstalk. I managed to get it working by including this "99_process_tasks.config" file in my .ebextensions folder (based on this in the AWS documentation)
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: |
date > /tmp/date
source /opt/python/run/venv/bin/activate
cd /opt/python/current/app
python manage.py process_tasks
commands:
remove_old_cron:
command: "rm -f /etc/cron.d/*.bak"
This worked because asynchronous tasks were being executed and their code was being executed, as expected.
, (, cron), , , , , , , python manage.py process_tasks . , , - ( , , ). @reboot, , , , , , .
cron, , ? , ?