My Cron Setup is:
0 * * * * ruby /directory/to/ruby/file.rb
And I get this error:
/usr/lib64/ruby/1.9.3/rubygems/custom_require.rb:36:in `require': cannot load such file -- mechanize (LoadError)
from /usr/lib64/ruby/1.9.3/rubygems/custom_require.rb:36:in `require'
from /home4/ofixcom1/rails_apps/products.rb:3:in `<main>'
When I run that script on SSH it runs without a problem, but when I cron setup it gives me this error. I have read a lot of solutions. Even with RVM and I tried them almost all.
A previous cron with ruby was running smoothly I dont know why it is not working with mine.
I forgot to mention, on the JustHost help they have this link with examples for other codes:
rvm has a page dedicated to using RVM wrappers with
cron. Basically, you can
rvm's alias wrappers
rvmenvironment in a shell script that is being invoked by
On the cron command line type:
bash -l -c '/home4/USER/public_html/code.rb'
On top of your code.rb file add:
and also open and edit.bashcr just to make sure you have the gems directory included.
export HPATH=$HOME export GEM_HOME=$HPATH/ruby/gems export GEM_PATH=$GEM_HOME:/lib64/ruby/gems/1.9.3 export GEM_CACHE=$GEM_HOME/cache export PATH=$PATH:$HPATH/ruby/gems/bin export PATH=$PATH:$HPATH/ruby/gems
special thank you to Jordan, who gave me the answer to this issue.
note: when doing a full justhost wipeout. and inserting whereis ruby command I had to change