簡體   English   中英

在生產模式下,cron作業無法在紅寶石上正常工作

[英]cron job is not working in ruby on rails in production mode

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

我建議不要使用自定義的capistrano任務,無論何時只要gem都加載由capistrano提供的任務。

添加到deploy.rb

require 'whenever/capistrano'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM