title: Crontab in Amazon Elastic Beanstalk
body: <p>I am doing a cron tab in AWS - Elastic Beanstalk with Ruby on Rails 3, but I don't know what is wrong.</p>
  
  <p>I have this code in my <strong>.ebextensions/default.config</strong></p>
  
  <pre><code>container_commands:
    01remove_old_cron_jobs:
      command: "crontab -r || exit 0"
    02send_test_email:
      command: crontab */2 * * * * rake send_email:test
      leader_only: true
  </code></pre>
  
  <p>I receive this error:</p>
  
  <pre><code>Failed on instance with return code: 1 Output: Error occurred during build: Command 02send_test_email failed .
  </code></pre>
  
  <p><strong>UPDATE 1</strong></p>
  
  <p>I tried next:</p>
  
  <p><strong>crontab.txt</strong></p>
  
  <pre><code>*/2 * * * * rake send_email:test &gt; /dev/null 2&gt;&amp;1
  </code></pre>
  
  <p><strong>default.config</strong></p>
  
  <pre><code>02_crontab:
    command: "cat .ebextensions/crontab.txt | crontab"
    leader_only: true
  </code></pre>
  
  <p>RESULT: No errors, but it does not work.</p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p><strong>crontab.sh</strong></p>
  
  <pre><code>crontab -l &gt; /tmp/cronjob
  #CRONJOB RULES
  echo "*/2 * * * * /usr/bin/wget http://localhost/crontabs/send_test_email &gt; /dev/null 2&gt;&amp;1" &gt;&gt; /tmp/cronjob
  #echo "*/2 * * * * rake send_email:test &gt; /dev/null 2&gt;&amp;1" &gt;&gt; /tmp/cronjob
  
  crontab /tmp/cronjob
  rm /tmp/cronjob
  echo 'Script successful executed, crontab updated.'
  </code></pre>
  
  <p><strong>default.config</strong></p>
  
  <pre><code>02_crontab:
    command: "/bin/bash .ebextensions/crontab.sh"
    leader_only: true
  </code></pre>
  
  <p>RESULT: Works with url, but not with rake task.</p>