为什么 #!/usr/bin/env ruby​​ 在 crontab 中不起作用? [英] why #!/usr/bin/env ruby doesn't work in crontab?

查看:23
本文介绍了为什么 #!/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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆