5

I have a web app running on elastic beanstalk. For some reason I was able to install the composer files in order to run my laravel app. The problem is that no other config file works. I have put newrelic.config into the .ebextensions/ directory, but that file got ignored.

I recently tried to create a cron job using this, AWS Elastic Beanstalk, running a cronjob, but it is not working.

Example of a .config file:

container_commands:
  01_some_cron_job:
    command: "cat .ebextensions/some_cron_job.txt > /etc/cron.d/some_cron_job && chmod 644 /etc/cron.d/some_cron_job"
    leader_only: true

When I ssh into the ec2 instance, there is no such directory as some_cron_job.

The source gets committed to beanstalk, but beanstalk is not running the commands.

How can I make beanstalk acknowledge the .config files. Fixing this cronjob will also fix installing new relic, because both configs are being ignored and I do not know why.

Community
  • 1
  • 1
Ken
  • 193
  • 1
  • 9

3 Answers3

0

Try putting it in commands section. It is more of a server command than a container command.

commands:
  01_some_cron_job:
    command: "cat .ebextensions/some_cron_job.txt > /etc/cron.d/some_cron_job && chmod 644 /etc/cron.d/some_cron_job"
    leader_only: true
Gustaf
  • 1,299
  • 8
  • 16
0

I had similar issues as well using container_commands and files, however, I deferred to the files event and it worked like a charm. My specific setup is as below.

.ebextensions/cron.config

files:
  "/etc/cron.d/mycronstuff":
       mode: "000644"
      owner: root
      group: root
    content: |
         # Run daily job every 8 hours
         0 */8 * * * root curl -i XXXXXXXXXX
         # Run nightly job at 2AM (8AM UTC)
         0 8 * * * root curl -i XXXXXXXXX
Napoli
  • 1,389
  • 2
  • 15
  • 26
0

Update 2019:

You must use a cron.yaml file on your project directory.

inside the file you can mention:

version: 1
 cron: 
   - name: "task1"
     url: "/scheduled"
     schedule: "* * * * *"
Bira
  • 4,531
  • 2
  • 27
  • 42