dimanche 20 décembre 2020

How to add Laravel scheduled tasks as cronjob on AWS Elastic Beanstalk?

I tried many different solutions that I found but none of them worked! Here are the links that I already tried without any luck:

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

I need to regularly truncate a table in DB which is used for caching purposes (PHP artisan truncate:cached_stores).

According to the documentation, I created mycron.config in .ebextensions folder in the root directory of my Elastic Beanstalk laravel app with many different contents based on the solutions I found such as the followings:

    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"

Also this:

    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"

I appreciate it if you could help me what am I missing?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire