0

I am trying to run a .ebextantions/01-main.config with below command. In shell check, it looks fine. But, while executing same getting below error:

container_commands:
  01_cron_job:
    command: docker exec -d -w /var/www/kiu/central "$(docker ps -aqf \"name=kiu-central\")" sh -c \"cat .ebextensions/kuicron.txt > /etc/cron.d/kuicron && chmod 644 /etc/cron.d/kuicron\"
    leader_only: true


Command failed on instance. Return code: 1 Output: Error response from daemon: Invalid filter '"name'
Error: No such container: sh.
Jaishree Mishra
  • 545
  • 2
  • 5
  • 24

1 Answers1

0

I am able to resolve same. Saw these two articles. https://forums.aws.amazon.com/message.jspa?messageID=665468#665468 AWS Elastic Beanstalk, running a cronjob

Dockerrun.aws.json

  "Volumes": [
    {
      "HostDirectory": "/tmp/is_leader",
      "ContainerDirectory": "/tmp/is_leader"
    }

.ebextensions/ 01-main.config

/opt/elasticbeanstalk/hooks/appdeploy/post/98_build_app.sh: 
    content: |
        #!/usr/bin/env bash
        FILE=/tmp/is_leader
        if test -f "$FILE"; then
            echo "$FILE exist"
            docker exec -d -w /var/www/kiu/central "$(docker ps -aqf "name=kiu")" sh -c "service cron start"
            docker exec -d -w /var/www/kiu/central "$(docker ps -aqf "name=kiu")" sh -c 'crontab -l | { cat; echo "* * * * * cd /var/www/kiu/central && /usr/local/bin/php artisan schedule:run >> cron.txt 2>&1"; } | crontab -'
          else
            echo "is_leader not exists"
          fi
    group: root
    mode: "000755"
    owner: root
Jaishree Mishra
  • 545
  • 2
  • 5
  • 24