Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/57.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.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
Ruby on rails Cron作业没有';t运行';跑步者';使用Sidekiq的任务_Ruby On Rails_Ruby_Cron_Sidekiq_Whenever - Fatal编程技术网

Ruby on rails Cron作业没有';t运行';跑步者';使用Sidekiq的任务

Ruby on rails Cron作业没有';t运行';跑步者';使用Sidekiq的任务,ruby-on-rails,ruby,cron,sidekiq,whenever,Ruby On Rails,Ruby,Cron,Sidekiq,Whenever,我使用gem生成了一个Cront作业 every 15.minutes do command "date >> ~/cron.txt" runner "Location.update_days" end 通过在命令行中键入crontab-l,我得到: 0,15,30,45 * * * * /bin/bash -l -c 'date >> ~/cron.txt' 0,15,30,45 * * * * /bin/bash -l -c 'cd /opt/ww

我使用gem生成了一个Cront作业

every 15.minutes do
    command "date >> ~/cron.txt"
    runner "Location.update_days"
end
通过在命令行中键入
crontab-l
,我得到:

0,15,30,45 * * * * /bin/bash -l -c 'date >> ~/cron.txt'

0,15,30,45 * * * * /bin/bash -l -c 'cd /opt/www/my_app && bin/rails runner -e production '\''Location.update_days'\'''
显然,
命令
任务工作正常,我每隔15分钟将
日期
打印到
cron.txt
,但是
运行程序
任务没有运行

Location.update\u days
调用Sidekiq worker来执行任务,它在从
rails控制台运行时工作,但在cron调用时不工作

def self.update_days
   new_day = self.new_day

   self.where( current_location: true,
            self.season => new_day[:timezone]
          ).find_each do |location|
            day = location.days.create new_day
            SidekiqWorker.perform_async day.id
          end
end

你知道什么地方出了问题,或者我如何调试这个问题吗?

我知道你说它可以从控制台运行,但是你试过运行cron作业运行的bash脚本来查看是否有明显的错误吗?在Ruby类加载之前,cron作业可能会失败

/bin/bash -l -c 'cd /opt/www/my_app && bin/rails runner -e production '\''Location.update_days'\'''

是的,它会提示我到新行,在行的开头显示一个
,就像在
rails控制台中一样,但是如果我键入类似Location.first的内容并按enter键,只会提示我转到另一个新行,而不显示任何结果。你认为这是为什么?显然是反斜杠造成的问题。如果没有它们,它可以在控制台中工作,但这有点奇怪,因为它们是由
$bin/rails runner-e production'Location.update_days'