【发布时间】:2013-12-05 17:25:00
【问题描述】:
我正在 AWS - Elastic Beanstalk 中使用 Ruby on Rails 3 做一个 cron 选项卡,但我不知道出了什么问题。
我的 .ebextensions/default.config
中有这段代码container_commands:
01remove_old_cron_jobs:
command: "crontab -r || exit 0"
02send_test_email:
command: crontab */2 * * * * rake send_email:test
leader_only: true
我收到此错误:
Failed on instance with return code: 1 Output: Error occurred during build: Command 02send_test_email failed .
更新 1
接下来我尝试了:
crontab.txt
*/2 * * * * rake send_email:test > /dev/null 2>&1
default.config
02_crontab:
command: "cat .ebextensions/crontab.txt | crontab"
leader_only: true
结果:没有错误,但它不起作用。
更新 2
crontab.sh
crontab -l > /tmp/cronjob
#CRONJOB RULES
echo "*/2 * * * * /usr/bin/wget http://localhost/crontabs/send_test_email > /dev/null 2>&1" >> /tmp/cronjob
#echo "*/2 * * * * rake send_email:test > /dev/null 2>&1" >> /tmp/cronjob
crontab /tmp/cronjob
rm /tmp/cronjob
echo 'Script successful executed, crontab updated.'
default.config
02_crontab:
command: "/bin/bash .ebextensions/crontab.sh"
leader_only: true
结果:适用于 url,但不适用于 rake 任务。
【问题讨论】:
标签: ruby-on-rails amazon-web-services cron amazon-elastic-beanstalk rake-task