【发布时间】:2011-11-13 15:29:03
【问题描述】:
Cron 作业在 Rails 3 中不起作用。我正在使用 gem 这是我正在使用的代码。
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
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 cron scheduled-tasks