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

c2h*_*2h2 8 ruby crontab ruby-on-rails-3

我有RVM(系统级)安装Ruby,并通过正常的控制台工作正常,我的轨程序与这两个行为正确rails runnerapache2+passenger.

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

/usr/bin/env: ruby: No such file or directory
Run Code Online (Sandbox Code Playgroud)

任何人都知道为什么/ usr/bin/env在crontab中不起作用?

dre*_*obb 7

如果你通过rvm安装了ruby,ruby可能不在/ usr/bin中.根据rvm的安装位置:

bash -c "source /usr/local/lib/rvm" && rails runner foo.bar
Run Code Online (Sandbox Code Playgroud)

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