为什么 #!/usr/bin/env ruby​​ 在 crontab 中不起作用?

编程入门 行业动态 更新时间:2024-10-21 19:41:37
本文介绍了为什么 #!/usr/bin/env ruby​​ 在 crontab 中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过 rvm(系统范围)安装了 ruby​​,并通过普通控制台正常工作,我的 rails 程序在 rails runnerapache2+passenger 上都正常运行.

I have install ruby by rvm (system-wide), and worked correctly via normal console and my rails program is behaving correctly with both rails runner and apache2+passenger.

现在在 crontab 中,我调用了 rails runner foo.bar,它放弃了,仔细检查我看到的日志:

Now in a crontab, I called rails runner foo.bar, it gives up, carefully examine the log i see that:

/usr/bin/env: ruby: No such file or directory

有谁知道为什么/usr/bin/env 在 crontab 中不起作用?

Anyone knows why /usr/bin/env doesnt work in crontab?

推荐答案

如果您通过 rvm 安装了 ruby​​,则 ruby​​ 可能不在/usr/bin 中.取决于 rvm 的安装位置:

If you installed ruby via rvm, ruby probably isn't in /usr/bin. Depending on where rvm is installed:

bash -c "source /usr/local/lib/rvm" && rails runner foo.bar

您可能在 bashrc 中添加了一个源 */rvm,这是正确的 rvm 加载脚本.

You probably added a source */rvm to your bashrc that is the correct rvm loading script.

这篇关于为什么 #!/usr/bin/env ruby​​ 在 crontab 中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-03-27 04:27:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/679045.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中不   bin   usr   env   crontab

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!