【问题标题】:Whenever gem not working rails 4每当 gem 不工作 rails 4
【发布时间】:2015-10-05 14:51:46
【问题描述】:

我遵循了 When 教程并安装了 gem。我正在使用 Ubuntu。我在模型中写了这个方法:

def self.cron_job
  puts "am in cron"
  InspectionReport.all
  logger.info Time.now.to_s
  InspectionReport.all.each do |ins|
    ins.date = ins.date+1.month
    ins.save!
  end
end

schedule.rb 中的代码:

set :output, "/log/cron.log" 
every 1.minute do   
runner "InspectionReport.cron_job", :environment => :development  
rake update_inspection_reports end

一分钟后什么都没有发生。有什么想法吗?

【问题讨论】:

    标签: ruby-on-rails cron whenever


    【解决方案1】:

    在 schedule.rb 文件中试试这个代码。它对我有用:

    #for default path related issue
    env :PATH, ENV['PATH']
    
    every 1.minute do
      runner "InspectionReport.cron_job", :output => 'log/cron.log'
      rake update_inspection_reports , :output => 'log/cron.log'
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-31
      • 1970-01-01
      • 2014-01-12
      • 1970-01-01
      • 2018-06-19
      • 2015-02-28
      • 2011-11-24
      相关资源
      最近更新 更多