简体   繁体   中英

Elastic beanstalk cron with laravel schedule

I have just made two schedule in laravel. Register them in kernel like this

 $schedule->command('jobs:expire')->everyMinute();
 $schedule->command('jobs_schedule:notify')->everyMinute();

Made folder on root named .ebextensions and create file in it named cronjob.config with code below.

files:
  "/etc/cron.d/mycron":
    mode: "000644"
    owner: root
    group: root
    content: |
      * * * * * root . /opt/elasticbeanstalk/support/envvars && /usr/bin/php /var/www/html/project/artisan schedule:run 1>> /dev/null 2>&1

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

But it is not working on server. Other than that it runs through artisan command line successfully am mi missing out something?

It's highly likely you are running on Amazon Linux 2, in which case the environment variables are stored under /opt/elasticbeanstalk/deployment/env instead. Just replace the mentioned path in your config and you should be good.

Source: I followed similar guide and ran into the same issue.

I have the same problem. Laravel 7.29.3. EBS. PHP 7.4 running on 64bit Amazon Linux 2/3.3.6. Schedule exec but I think that env vars is not loading, because not connect with database. I can register in log messages.

My cronjob.config code:

files:
    "/etc/cron.d/schedule_run":
        mode: "000644"
        owner: root
        group: root
        content: |
            * * * * * root . /opt/elasticbeanstalk/deployment/env && /usr/bin/php /var/www/html/artisan schedule:run 1>> /var/www/html/laralog.log 2>&1

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

But a SQL error is generated at log.

SQLSTATE[HY000] [2002] Connection refused (SQL:...

Thanks for help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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