本文介绍了Rails3,从cron运行rake任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到问题从cron运行我的耙子任务,我将它包装在shell文件,当我从控制台执行这个shell文件工作正常。
I'm having problems running my rake task from cron, I wrap it in shell file and when I execute this shell file from console it works fine.
#!/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)
Entry in crontab looks like this(I set PATH and 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"
任何人都知道如何
推荐答案
我想出了解决方法 - 从源安装rails-设置
I came up with workaround - installing rails-settings from source
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中的rails-settings中删除:git =>
and you have to remove ":git =>" from gem "rails-settings" in Gemfile, and run
bundle install
更新Gemfile.lock
to update Gemfile.lock
之后,我的脚本从cron运行。
After that my script run from cron.
这篇关于Rails3,从cron运行rake任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!