我正在写一个Rake任务。我想在每个月的最后一个星期天晚上11点触发它
我如何在Ruby on Rails中使用任何时候的gem来安排这件事呢?
我的rake任务位于以下位置:app/lib/ task / my _task.rake
task :create_entries => :environment do
puts "Hello"
end 发布于 2015-09-25 23:30:25
我不认为有“每月的最后一天”的规则,但你总是可以在代码块中放一个额外的if测试:
every :sunday, :at => '11pm' do
#if the month is different a week from now, we must be in the last
#sunday of the month
if Time.now.month != 1.week.from_now.month
rake "my:rake:task"
end
end因此,这段预定的代码将在每个星期天运行,但只有在时间满足进一步的条件时,它才会继续调用rake任务。
https://stackoverflow.com/questions/32785557
复制相似问题