【发布时间】:2011-08-09 14:13:27
【问题描述】:
我刚刚获得了 Heroku cron 的付费版本,以便每小时运行一些任务。我想知道的是我应该使用的语法来实际让它每小时运行一次。到目前为止我有这个,请你告诉我它是否正确:
desc "Tasks called by the Heroku cron add-on"
task :cron => :environment do
if Time.now.hour % 1 == 0 # run every sixty minutes?
puts "Updating view counts...."
Video.update_view_counts
puts "Finished....."
puts "Updating video scores...."
VideoPost.update_score_caches
puts "Finished....."
puts "Erasing videos....."
Video.erase_videos!
puts "Finished....."
end
if Time.now.hour == 0 # run at midnight
end
end
我需要知道这条带有 1 的行是否是要走的路...
if Time.now.hour % 1 == 0
提前感谢您的帮助,
最好的问候。
【问题讨论】:
标签: ruby-on-rails cron heroku jobs