Cronjob is not ran in Elastic Beanstalk

I am running Django in Elastic Beanstalk, platform: Python 3.7 running on 64bit Amazon Linux 2/3.4.0.

I need to create a cronjob that runs a custom Django management command once every five minutes.

I created the following file to .ebextensions/cron.config:

files:
    "/etc/cron.d/mycron":
        mode: "000644"
        owner: root
        group: root
        content: |
            5 * * * * root /usr/local/bin/myscript.sh
    "/usr/local/bin/myscript.sh":
        mode: "000755"
        owner: root
        group: root
        content: |
            #!/bin/bash
            source /var/app/venv/*/bin/activate && python3 manage.py mycommand
            exit 0
commands:
    remove_old_cron:
        command: "rm -f /etc/cron.d/mycron.bak"

And redeployed the enviroment with eb deploy. However, the cron job does not get run.

My questions are:

  • What have I done wrong?
  • How can I see if the cron.config file gets processed?
  • How can I check that some cronjob gets ran?
Back to Top