6
我遵循所有的步驟,每當在Gemfile中的一些無法使用的cronjob每當運行在導軌3
gem 'whenever', :require => false
輸出參考https://github.com/javan/whenever
在schedule.rb
require 'yaml'
set :environment, 'production'
set :output, {
:error => "/log/error.log",
:standard => "/log/cron.log"
}
every 1.minute do
runner "User.weekly_update"
end
命令
localhost:〜/ project $ when -i
[write] crontab file updated
本地主機:〜/ $項目的crontab -l
# Begin Whenever generated tasks for: /home/bacancy/project/config/schedule.rb
* * * * * /bin/bash -l -c 'cd /home/bacancy/project && script/rails runner -e production '\''User.weekly_update'\'' >> /log/cron.log 2>> /log/error.log'
# End Whenever generated tasks for: /home/bacancy/project/config/schedule.rb
# Begin Whenever generated tasks for: store
* * * * * /bin/bash -l -c 'cd /home/bacancy/project && script/rails runner -e development '\''User.weekly_update'\'''
# End Whenever generated tasks for: store
# Begin Whenever generated tasks for: lapulguilla
# End Whenever generated tasks for: lapulguilla
然後我鍵入
本地主機:〜/ $項目每當
* * * * * /bin/bash -l -c 'cd /home/bacancy/project && script/rails runner -e production '\''User.weekly_update'\'' >> /log/cron.log 2>> /log/error.log'
## [message] Above is your schedule file converted to cron syntax; your crontab file was not updated.
## [message] Run `whenever --help' for more options.
在用戶模式,我有定義self.weekly_update
def self.weekly_update
puts "cronjobs is called in every minutes"
end
它沒有運行在每分鐘cron作業。我在這方面犯了哪些錯誤?我怎麼能每分鐘運行一次? – 2013-04-06 05:47:49
嗨Nirav,我已經經歷了你的問題,並根據我的觀點,cron工作必須工作,但在邏輯上有一些錯誤,你可以請從'/log/error.log'文件發佈錯誤代碼... – Jeet 2013-04-15 08:57:30
嗨Jeet,它不會爲cronjob創建日誌文件。是什麼具體原因?錯誤我已經提到。如果我每次都運行,它不會完美運行。看主帖的最後一行。 – 2013-04-15 09:23:39