[英]Whenever gem not working rails 4
I had followed the Whenever tutorials and installed the gem. 我已经遵循了每当时间教程并安装了gem。 I'm using Ubuntu. 我正在使用Ubuntu。 I have written this method in the model: 我已经在模型中编写了此方法:
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
Code in schedule.rb: schedule.rb中的代码:
set :output, "/log/cron.log"
every 1.minute do
runner "InspectionReport.cron_job", :environment => :development
rake update_inspection_reports end
Nothing happens after a minute. 一分钟后没有任何反应。 Any ideas? 有任何想法吗?
Try this code in schedule.rb file. 在schedule.rb文件中尝试此代码。 it is working for me: 它为我工作:
#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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.