【问题标题】:A command of the gem whenever in cron doesn't work每当在 cron 中的 gem 的命令不起作用时
【发布时间】:2017-12-25 17:49:38
【问题描述】:

我有一个简单的 Rails 应用程序无论何时都带有 gem。还有一个模块:

module Module1
  class << self
    def say_hi
      puts "hi123"
    end
  end
end

当我设置 每当 时,它会将这个添加到 cron:

* * * * * /bin/bash -l -c 'cd /home/user123/my_app && bundle exec script/runner -e production '\''Module1.say_hi'\'''

它不起作用。当我直接在终端中运行它时,这个命令返回:

/bin/bash: bundle: command not found

然后我试试这个:

cd /home/user123/my_app && bundle exec script/runner -e production 'Module1.say_hi'

现在一个错误是:

bundler: command not found: script/runner

但是,我的 rails 应用程序运行良好; bundle 和其他东西都安装好了。

【问题讨论】:

标签: ruby-on-rails ruby linux cron


【解决方案1】:

您还可以通过将以下内容放在 schedule.rb 文件的顶部来确保您的 PATH 最终出现在 crontab 中:

env :PATH, ENV['PATH']

chek this 如果上述解决方案不适合您,请尝试:

env :GEM_PATH, ENV['GEM_PATH']

【讨论】:

    猜你喜欢
    • 2011-11-24
    • 1970-01-01
    • 2015-02-28
    • 1970-01-01
    • 2016-03-01
    • 1970-01-01
    • 2017-09-19
    • 1970-01-01
    • 2014-04-01
    相关资源
    最近更新 更多