我有一个简单的红宝石脚本hello.rb
:
#!/usr/bin/env ruby
puts 'hello'
它在命令行运行正常:
# /usr/local/src/hello/hello.rb
hello
但是,如果我把它放在cron
:
* * * * * /usr/local/src/hello/hello.rb >> /usr/local/src/hello/hello.log 2>&1
日志文件中有错误:
/usr/bin/env: ruby: No such file or directory
/usr/bin/env: ruby: No such file or directory
...
/usr/bin/env: ruby: No such file or directory
/usr/bin/env ruby
虽然在命令行运行正常:
# /usr/bin/env ruby -v
ruby 1.8.7 (2012-10-12 patchlevel 371) [i686-linux]
如何修复环境错误cron
?