简体   繁体   English

Cron 作业 Django Elastic Beanstalk

[英]Cron job Django Elastic Beanstalk

I am trying to set a cron job on my project to send a email after 15 minutes.我正在尝试在我的项目上设置一个 cron 作业,以便在 15 分钟后发送电子邮件。

This is in django.config这是在 django.config

04_cronjb:
    command: "cat .ebextensions/cron-linux.config > /etc/cron.d/crontab && chmod 644 /etc/cron.d/crontab"
    leader_only: true

This is my cron-linux.config file这是我的 cron-linux.config 文件

files:
    "/etc/cron.d/mycron":
        mode: "000644"
        owner: root
        group: root
        content: |
            

            * * * * * source /opt/python/current/env && python /opt/python/current/app/manage.py cronjb

It all deploys successfully but i am not receiving any email.一切都部署成功,但我没有收到任何电子邮件。 Cronjb script is working i have tested it. Cronjb 脚本正在运行,我已经对其进行了测试。 So the error is one these two files.所以错误是这两个文件之一。 Is there some mistake in it?有什么错误吗?

Your 04_cronjb copies entire content of cron-linux.config into crontab .您的04_cronjbcron-linux.config全部内容复制到crontab This is sadly incorrect.遗憾的是,这是不正确的。

Instead you should do as shown here .相反,您应该按照此处所示进行操作。 This includes putting all the bash commands you want to execute in a custom script called, eg, myscript.sh and then adding myscript.sh to cron only.这包括将您要执行的所有 bash 命令放在一个名为myscript.sh的自定义脚本中,然后仅将myscript.sh添加到 cron。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM