awsdocs / elastic-beanstalk-samples

This repository contains code and configuration samples (e.g. .ebextensions) for AWS Elastic Beanstalk.
Apache License 2.0
1.22k stars 889 forks source link

Unable to run cron on AMI 2 PHP Laravel due to environment variables not being accessible #141

Closed Ali-Shaikh closed 3 years ago

Ali-Shaikh commented 4 years ago

I have followed the instruction here https://aws.amazon.com/premiumsupport/knowledge-center/elastic-beanstalk-env-variables-linux2/

and then created a corn like this

#!/bin/sh

# Create CRON files

# After the deployment finishes, set up a Crontab for
# the php artisan schedule:run command
echo "* * * * * ec2-user source <(sed -E -n 's/[^#]+/export &/ p' /opt/elasticbeanstalk/deployment/envvars) && /usr/bin/php /var/app/current/artisan schedule:run 1>> /dev/null 2>&1" \
  | sudo tee /etc/cron.d/artisan_scheduler

but it is not working. The application fails to execute the commands because the env vars are not accessible. I have tried creating cron jobs for root, webapp and ec2-user users but nothing is working.

Any help I can get would be much appreciated.

Ali-Shaikh commented 4 years ago

Managed to figure it out https://github.com/AWSomeTech/aws-eb-laravel

mrenneke-amazon commented 3 years ago

Hi @Ali-Shaikh --

I am glad that you were able to figure out this issue. Thank you for sharing your solution. We will take a look at the link you provided and consider the contents for fixing our documentation.

Thanks, and sorry it took us so long to get back to you.

ma-za-kpe commented 2 years ago

So the link you shared is broken

nafil-gigsboard commented 2 years ago

The code not working