Running cron jobs on aws elastic beanstalk - django

后端 未结 2 1312
没有蜡笔的小新
没有蜡笔的小新 2021-02-09 18:05

I\'m having trouble getting my cron jobs to execute.

Setup:

Django - 1.9

Elastic beanstalk - 64bit Amazon Linux 2016.03 v2.1.3 running Python 3.4

相关标签:
2条回答
  • 2021-02-09 18:25

    2018 Update using Django 2.0.6 + AWS ElasticBeanstalk + Cronjob

    I found I needed to export the AWS environment variables using source /opt/python/current/env to prevent manage.py from throwing the error "The SECRET_KEY setting must not be empty".

    This is because I had placed my Django Secret key in the os.environ for beanstalk which it seems is not accessible by shell/cron by default.

    See https://forums.aws.amazon.com/thread.jspa?threadID=108465

    My final cron job .txt script was as follows. (process_emails is my own django management function, myjob.log is where the output of the function call is logged).

    */15 * * * * source /opt/python/run/venv/bin/activate && cd /opt/python/current/app/ && source /opt/python/current/env && python manage.py process_emails >> /var/log/myjob.log 2>&1
    
    0 讨论(0)
  • 2021-02-09 18:32

    This works for me in Django 1.10.6 + AWS ElasticBeanstalk + Cronjob

    * * * * * source /opt/python/run/venv/bin/activate && cd /opt/python/current/app/ && python manage.py do_your_thing > $HOME/cron-sqs.log 2>&1

    do_your_thing is a management command

    0 讨论(0)
提交回复
热议问题