0
cron作業在rails 3中無法正常工作。我每當使用gem時都使用下面是我正在使用的代碼。cron作業在生產模式下不能在rails上運行ruby
schedule.rb文件
every 1.hours do
command "cd /home/me/my_app/current"
rake "thinking_sphinx:index RAILS_ENV=production"
end
every 1.day, :at => '12.01 am' do
command "cd /home/me/my_app/current"
rake "messages_counter_for_user_and_group RAILS_ENV=production"
command "cd /home/me/my_app/current"
runner "RAILS_ENV=production User.update_all(:daily_message_count => 0)"
end
從Capistrano的部署腳本: -
task :long do
transaction do
cron_tab_activate
end
task:cron_tab_activate, :roles=>:app do
send(run_method, "cd #{current_path} && RAILS_ENV=#{stage} whenever --update-crontab test ")
end
我使用RVM。 Ruby 1.9.2,Rails 3.0.10