I use Ubuntu, I try run my rake task from cron My rake task:
namespase :import do
task :import_twitter => :environment do
puts "Twitter importing...."
end
end
schedule.rb file
every 1.minutes do
rake "import:import_twitter", :output => {:error => 'error.log', :standard => 'cron.log'}
end
with whenever I generate crontab task
# Begin Whenever generated tasks for: /home/administrator/www/my_application/config/schedule.rb
PATH=/usr/local/rvm/gems/ruby-1.9.2-p0/bin:/bin:/usr/local/rvm/rubies/ruby-1.9.2-p0/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
* * * * * cd /home/administrator/www/my_application && RAILS_ENV=production /usr/bin/env rake import:import_twitter >> cron.log 2>> error.log
# End Whenever generated tasks for: /home/administrator/www/my_application/config/schedule.rb
In crontab error.log I have
/usr/local/rvm/rubies/ru开发者_运维知识库by-1.9.2-p0/lib/ruby/1.9.1/rubygems.rb:340:in `bin_path': can't find executable rake for rake-0.8.7 (Gem::Exception)
from /usr/local/rvm/gems/ruby-1.9.2-p0/bin/rake:19:in `<main>'
But when I run this task from console it work
path_to_my_project >rake import:import_twitter
What's wrong?
I have the same issue with rvm and whenever. If I want it's works I define the HOME VARIABLE and comment the PATH variable and it's works.
I thinks it's a rvm issue with loading of your environment.
# Begin Whenever generated tasks for: supermarmite
SHELL=/bin/bash
HOME=/var/rails/supermarmite
#PATH=/var/rails/supermarmite/.rvm/gems/ruby-1.9.2-p0/bin:/var/rails/supermarmite/.rvm/gems/ruby-1.9.2-p0@global/bin:/var/rails/supermarmite/.rvm/rubies/ruby-1.9.2-p0/bin:/var/rails/supermarmite/.rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/mongodb/bin
0 * * * * source ~/.bashrc && cd /var/rails/supermarmite/site/releases/20100930044915 && RAILS_ENV=production rake -s evaluate_notify
# End Whenever generated tasks for: supermarmite
精彩评论