Ruby on Rails的crontab任务已被调度,但未运行



我使用每当gem创建rake任务,我希望得到一个行输出"教塔博如何安排任务"在我的终端上每2分钟,我是新的Rails,这里是我的rake任务文件的代码,我命名为request_invoice。rake

 namespace :request_invoice do
  desc "Teaching Thabo how to schedule tasks"
  task test_tasking: :environment do
  puts "Learning the tasking in rails..."
  end
 end

和每当gem创建一个时间表。在我的项目配置中的Rb文件中,我在文件

中有以下代码
 every 2.minutes do
 rake 'request_invoice:test_tasking'
 end

我在终端上运行了whatever命令,它给出了以下内容:

    0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,5 2,54,56,58 /bin/bash -l -c 'cd /home/sable/GMS/grading-     management-solution && RAILS_ENV=production bundle exec rake    request_invoice:test_tasking --silent'
## [message] Above is your schedule file converted to cron syntax; your crontab file was not updated.
## [message] Run `whenever --help' for more options.

你有没有运行:

whenever --update-crontab

命令吗?根据gem的页面,这是更新crontab文件所必需的。

首先,您需要使用:

检查您是否已向crontab添加了任务
crontab -e

如果您没有看到您的任务,然后添加它使用:

whenever -i

您可以通过设置日志文件来跟踪cron作业。只需将以下内容添加到config/schedule.rb的顶部:

set :output, "log/cron_log.log"

现在,您应该能够检查您的cron日志(如果您可以使用tail,那么从应用程序路径的根目录执行以下操作):

tail -f log/cron_log.log

最新更新