Fabrice Lefloch
Fabrice Lefloch

Reputation: 417

Scheduled task on AWS Elastic beanstalk not running

I have a Laravel application running on EC2 instance handled by Elastic Beanstalk. To handle some cron job I used the script provided by AWS here https://github.com/awsdocs/elastic-beanstalk-samples/blob/master/configuration-files/aws-provided/instance-configuration/cron-leaderonly-linux.config And some extra informations provided by Macin in this thread Laravel Scheduling Task on AWS is not working

Everything is working exactly as they should on my staging environment, but in production the cron task doesn't seem to be triggered.

Both environnement are supposed to be exactly the same (platform version is "PHP 7.4 running on 64bit Amazon Linux 2"). I tried to run sudo service crond status and I can see this line at the time I deployed the app (*system*) RELOAD (/etc/cron.d/cron_example).

Also in /var/log/cron file I can see for everyminute (root) CMD (/usr/local/bin/cron_example.sh) so it seems like everything is running fine, but /tmp/cron_example.log isn't created and my real task isn't executed either.

Does anyone has an idea on what I could do to understand what is blocking it? Is there some extra log file I could consult to find out what is going on?

Thank you for your help.

Upvotes: 0

Views: 1149

Answers (1)

Fabrice Lefloch
Fabrice Lefloch

Reputation: 417

With the help of AWS technical team I was finally able to fix this CRON not running error. It turns out that the IAM role which was making the deployment in my ElasticBeanstalk didn't have the ec2:DescribeTag role (it was having the elasticbeanstalk:DescribeTag role). At that time I still don't know why the exact same role were running correctly on my staging environment and not in the production one.

Upvotes: 1

Related Questions