问题描述
我试图运行一个ruby脚本使用rbenv与cron。
我知道我需要加载rbenv为了加载正确的ruby版本。
I'm trying to run a ruby script using rbenv with cron.I know that I need to load rbenv in order to have the right ruby version loaded.
我已经尝试过这样的选项:
I've tried options like this :
但是由于会话不是交互式的, m没有正确的ruby版本。
我发现这样的例子:
but as the session is not interactive, I'm not having the right ruby version.I've found example like this :
更紧密。然后我写了一个加载器,只加载rbenv在当前shell,但它不工作。
It didn't work neighter. Then I wrote a loader, which only load rbenv in the current shell but it doesn't work.
现在我正在另一种方式加载它...任何想法?
Now I'm searching another way to load it ... any idea ?
推荐答案
我找到一个解决方案来加载rbenv。可以使用加载程序将rbenv导入到PATH:
I've found a solution to load rbenv. Either with a loader importing rbenv to the PATH :
在'$ HOME / .rbenv / loader.sh'之前的'。'很重要,它运行脚本在当前shell
The '.' before '$HOME/.rbenv/loader.sh' is important, it runs the script in the current shell
或没有加载器,这是更好的:
Or without loader, which is better :
这篇关于ruby脚本使用rbenv在cron的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!