Heroku cron工作帮助 [英] Heroku cron job help

查看:114
本文介绍了Heroku cron工作帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 我有我的cron.rake file:
desc这个任务由Heroku cron add-on调用
task:cron => :环境做
如果Time.now.hour%4 == 0#每四个小时运行一次
放置更新提要...
NewsFeed.update
putsdone。
end


解决方案

Heroku只提供每天或每小时cron工作,所以我认为你每运行15分钟就会运行cron作业。

相反,您可以使用 delayed_job 运行每15分钟工作一次。在每次运行结束时,你的工作代码应该创建另一份工作,在15分钟后运行。根据您的需求,您可以从工作开始或结束时计算15分钟。


How do I run the task reklamer:runall every 15 minutes in cron.rake?

I have my cron.rake file:
desc "This task is called by the Heroku cron add-on"
task :cron => :environment do
  if Time.now.hour % 4 == 0 # run every four hours
    puts "Updating feed..."
    NewsFeed.update
    puts "done."
  end

解决方案

Heroku only provides daily or hourly cron jobs so I think you're out of luck with running cron jobs every 15 minutes.

Instead, you could use delayed_job to run jobs every 15 minutes. At the end of each run, your job code should create another job which will run in 15 minutes. You could calculate 15 minutes from the start or the end of the job, depending on your needs.

这篇关于Heroku cron工作帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆