如何在 AWS Elastic Beanstalk 上将 Laravel 计划任务添加为 cronjob?

时间:2020-12-20 10:33:17

标签: laravel-5 cron amazon-elastic-beanstalk

我尝试了许多不同的解决方案,但都没有奏效! 以下是我已经尝试过但没有任何运气的链接:

  1. First
  2. Second
  3. Third
  4. Forth
  5. ...

我需要定期截断数据库中用于缓存的表(PHP artisan truncate:cached_stores)。

根据文档,我在 Elastic Beanstalk laravel 应用程序根目录下的 mycron.config 文件夹中创建了 .ebextensions,其中包含基于我找到的解决方案的许多不同内容,例如:

    files:
    "/etc/cron.d/schedule_run":
        mode: "000644"
        owner: root
        group: root
        content: |
            * * * * * root php /path-to-your-project/artisan schedule:run >> /dev/null 2>&1
commands:
    remove_old_cron:
        command: "rm -f /etc/cron.d/*.bak"

还有这个:

    files:
    "/etc/cron.d/mycron":
        mode: "000644"
        owner: root
        group: root
        content: |
            * * * * * root /usr/local/bin/myscript.sh

    "/usr/local/bin/myscript.sh":
        mode: "000755"
        owner: root
        group: root
        content: |
           * * * * * root . /opt/elasticbeanstalk/support/envvars && /usr/bin/php /var/www/html/artisan schedule:run 1>> /dev/null 2>&1

commands:
    remove_old_cron:
        command: "rm -f /etc/cron.d/*.bak"

如果您能帮助我,我会错过什么,我将不胜感激?

0 个答案:

没有答案