我試圖設置運行rake任務的cron作業。每當我使用寶石。這裏是Cron運行rake任務「無法在任何源中找到rake-0.8.7」
every 1.minutes do
bundle exec rake "test:pick_participant"
end
crontab中無論何時,只要正確設置在配置/ schedule.rb配置:
* * * * * /bin/bash -l -c 'cd /home/jsmith/webapp/releases/20111104200246 && RAILS_ENV=production bundle exec rake test:pick_participant --silent'
然而,克龍不斷報告(通過電子郵件)這個錯誤每次工作是跑:
From: [email protected] (Cron Daemon)
To: [email protected]
Subject: Cron <[email protected]> /bin/bash -l -c 'cd /home/jsmith/webapp/releases/20111104200246 && RAILS_ENV=production bundle exec rake test:pick_participant --silent'
Content-Type: text/plain; charset=ANSI_X3.4-1968
X-Cron-Env: <[email protected]>
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/jsmith>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=jsmith>
Message-Id: <[email protected]>
Date: Mon, 7 Nov 2011 16:26:01 -0800 (PST)
expr: syntax error
Could not find rake-0.8.7 in any of the sources
捆綁在應用程序環境中的rake版本是0.8.7。
由cron發出的命令似乎是正確的:
/bin/bash -l -c 'cd /home/jsmith/webapp/releases/2067320376 && RAILS_ENV=production bundle exec rake test:pick_participant --silent'
它直接調用bundle exec rake
代替rake
。
另外,如果我在發佈的應用程序目錄中的命令行相同的命令,rake任務運行成功:
[email protected]:~/webapp/current$ /bin/bash -l -c 'cd /home/jsmith/webapp/releases/20111104200246 && RAILS_ENV=production bundle exec rake test:pick_participant --silent'
* picked participant: Mindy!
任何人有,爲什麼cron是遇到了此問題的任何想法「找不到耙0.8.7" ?
感謝您在crontab中提及'/ bin/bash -l -c'。這也解決了我與捆綁商的問題。 – Roman
很棒的回答。感謝您分享您的解決方案。 –