【发布时间】:2015-12-07 05:10:51
【问题描述】:
我使用Whenever gem 生成了一个Cront Job
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'\'''
显然command 任务工作得很好,我确实每 15 分钟将date 打印到cron.txt,但runner 任务没有运行。
Location.update_days 调用 Sidekiq 工作程序来执行任务,它在从 rails console 运行时工作,但在被 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
您是否知道可能出了什么问题或者我该如何调试这个问题?
【问题讨论】:
标签: ruby-on-rails ruby cron sidekiq whenever