[英]Rails3, Running rake task from cron
我在從cron運行我的rake任務時遇到問題,我將它包裝在shell文件中,當我從控制台執行這個shell文件時,它運行正常。
#!/bin/sh
if ps -ef | grep -v grep | grep create_all_accounts ; then
exit 0
else
cd /home/prosoftstudio/www/prosoftstudio_egabinet && /home/prosoftstudio/www/.ruby/gems/1.8/bin/rake gabinet:create_all_accounts RAILS_ENV=production --trace
exit 0
fi
crontab中的條目看起來像這樣(我設置了PATH和GEM_PATH)
PATH=/home/prosoftstudio/www/.python/bin:/usr/local/python2.6/bin:/home/prosoftstudio/www/.ruby/gems/1.8/bin/:/usr/local/ruby1.8/bin:/usr/local/bin:/usr/bin:/bin:/us$
GEM_PATH=/home/prosoftstudio/www/.ruby/gems/1.8:/home/prosoftstudio/www/.ruby/gems/1.8/bundler/gems:/usr/lib/ruby/gems/1.8/
*/1 * * * * /home/prosoftstudio/www/cron_create_accounts.sh > cron_log.txt 2>&1
我得到的輸出是
rake aborted!
git://github.com/100hz/rails-settings.git (at master) is not checked out. Please run `bundle install`
好像它找不到安裝的寶石
gem "rails-settings", :git => "git://github.com/100hz/rails-settings.git"
有人知道怎么修這個東西嗎?
為了避免構建gem,另一個選擇是將gem內容放在vendor文件夾中並通過以下方式引用它:Gemfile中的path:
gem "my_gem", :path => "vendor/my_gem"
我提出了解決方法 - 從源代碼安裝rails-settings
wget https://github.com/100hz/rails-settings/zipball/master --no-check-certificate
unzip 100hz-rails-settings-v0.1.1-0-g330b958.zip
cd 100hz-rails-settings-330b958/
gem build rails-settings.gemspec
gem install rails-settings-0.1.1.gem
你必須從Gemfile中的gem“rails-settings”中刪除“:git =>”,然后運行
bundle install
更新Gemfile.lock
之后我的腳本從cron運行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.