2016-09-05 62 views
0

我使用的是每當gem創建rake任務時,我期待得到一個線輸出「在任務的教學Thabo如何安排任務」每2分鐘,我是新來的Rails,這裏是我有一個名爲request_invoice.rakeRuby on Rails crontab任務已安排但未運行

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

爲我耙任務文件中的代碼和寶石時在我的項目的配置創建一個schedule.rb文件,我有以下代碼

every 2.minutes do 
rake 'request_invoice:test_tasking' 
end 

我已經在終端上運行的命令時,它提供了以下:

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. 

回答

0

你運行:

whenever --update-crontab 

命令?根據gem's page,這是您的crontab文件被更新所必需的。

+0

是的,我確實運行了--update-crontab它給了回來這個:[write] crontab文件更新 – Teebo

0

首先,你需要檢查你是否已經添加任務crontab或不使用:

crontab -e 

如果你沒有看到你的任務,然後使用添加:

whenever -i 

你可以通過設置日誌文件來跟蹤您的cron作業。只需添加以下的config/schedule.rb頂部:

set :output, "log/cron_log.log" 

現在,你應該能夠檢查你的cron日誌(如果tail是提供給您,然後做你的應用程序的根路徑下):

tail -f log/cron_log.log 
+0

我可以看到任務,當我直接使用rake運行它時,我得到了出來,比如rake request_envoice :test_tasking – Teebo

+0

你輸入了'crontab -e',你能顯示結果嗎? – dp7

+0

它開放納米與此開始每當生成任務爲:/home/sable/GMS/grading-management-solution/config/schedule.rb 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,52,54,56,58 * * * */bin/b $ #結束每當生成任務爲:/home/sable/GMS/grading-management-solution/config/schedule.rb – Teebo