Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
每周运行任务,在Heroku上仅运行4次_Heroku_Ruby On Rails 3.2_Scheduler - Fatal编程技术网

每周运行任务,在Heroku上仅运行4次

每周运行任务,在Heroku上仅运行4次,heroku,ruby-on-rails-3.2,scheduler,Heroku,Ruby On Rails 3.2,Scheduler,我只想在周日运行一个rake任务4次 我想做以下几件事: 检查是否为星期天=>Time.now.wday=0 检查时间是否小于凌晨4点=>time.now

我只想在周日运行一个rake任务4次

我想做以下几件事:

  • 检查是否为星期天=>Time.now.wday=0
  • 检查时间是否小于凌晨4点=>time.now<4:00:00
  • 我会每小时运行一次任务

    语法:

    if Time.now.wday == 0 && Time.now < 4:00:00
                  rake "some_rake_task"
             end
    
    如果Time.now.wday==0&&Time.now<4:00:00
    耙“一些耙任务”
    结束
    

    上述方法行吗?

    我可以使用以下方法

    task :get_resource_scores => :environment do 
       #If this is in production mode or staging mode then only get the scores 4 times on Sunday between midnight and 4 am
       if  Time.now.wday == 7 && Time.now.hour < 5
         get_resource_scores
       end
    end
    
    task:get\u resource\u scores=>:environment do
    #如果这是在制作模式或舞台模式下,那么在周日午夜到凌晨4点之间只获得4次分数
    如果Time.now.wday==7&&Time.now.hour<5
    获取\u资源\u分数
    结束
    结束
    
    您如何安排Heroku上的作业?您使用的是Heroku调度程序插件,还是运行时钟系统实例的附加dyno,或者其他方式?