【问题标题】:Whenever ruby on rails每当红宝石在铁轨上
【发布时间】:2011-07-13 09:51:40
【问题描述】:

在我的日程安排中:

every 10.minutes do
  runner "Model.method"
end

每当在我的 crontabs 中创建它时

0,10,20,30,40,50 * * * * /bin/bash -l -c 'cd /home/projects/Monitoring && script/rails runner -e development '\''Model.method'\'''

我尝试在我的控制台中运行该命令并且它有效。为什么它不能自动工作,我要疯了!

在我的系统日志中

Mar 11 11:38:01 UbuntuRails CRON[20050]: (ruben) CMD (/bin/bash -l -c 'cd /home/projects/Monitoring && script/rails runner -e development '\''Ping.check_pings'\''')
Mar 11 11:38:01 UbuntuRails CRON[20048]: (CRON) info (No MTA installed, discarding output)
Mar 11 11:38:01 UbuntuRails CRON[20047]: (CRON) error (grandchild #20050 failed with exit status 1)
Mar 11 11:38:01 UbuntuRails CRON[20047]: (CRON) info (No MTA installed, discarding output)

【问题讨论】:

  • 你有本地运行的 cron 吗?您还可以在 schedule.rb 中添加 set :output, File.join(path, 'log', 'cron.log') 以记录输出。

标签: ruby-on-rails ubuntu cron crontab whenever


【解决方案1】:

我在 Ubuntu 10.10 上遇到了同样的问题。
原来 -l 选项不会按预期加载环境,但 -i 会。 (见this issue

正如问题线程所述,修复方法是编辑您的 schedule.rb 并添加:

set :job_template, "/bin/bash -i -c ':job'"

干杯

【讨论】:

    猜你喜欢
    • 2017-03-26
    • 2016-01-07
    • 1970-01-01
    • 2016-03-21
    • 1970-01-01
    • 2019-08-09
    • 1970-01-01
    • 2010-09-09
    • 1970-01-01
    相关资源
    最近更新 更多