I'm using a osx and I created a ruby script in the path:
*/1 * * * * 'ruby /Users/diogo/workspace/outros/crawler_trf/get_news.rb' > /tmp/crawler_trf.out
/bin/sh: ruby /Users/diogo/workspace/outros/crawler_trf/get_news.rb: No such file or directory
*/1 * * * * cd /Users/diogo/workspace/outros/crawler_trf/ && ruby get_news.rb > /tmp/crawler_trf.out
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- mail (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from get_news.rb:3:in `<main>'
You should always fully specify the paths of all files when executing them out of cron, since the environment provided by cron will be different from your login environment. That might mean replacing the invocation of
ruby with the full path to your ruby binary (maybe
ruby -v out of cron to see what version you are picking up. On my Mac OS system I have two:
Edwards-MacBook-Air:~ emv$ /usr/bin/ruby -v ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15] Edwards-MacBook-Air:~ emv$ /usr/local/bin/ruby -v ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
one from the operating system, and one from Homebrew.