Skip to content

Instantly share code, notes, and snippets.

@hectorperez
Created May 19, 2014 16:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hectorperez/49ca148209767ebeac0b to your computer and use it in GitHub Desktop.
Save hectorperez/49ca148209767ebeac0b to your computer and use it in GitHub Desktop.
Requiring a Ruby Gem in Ruby Script breaks Cron Job Execution: rvm cron setup
You need to setup your crontab with rvm e.g:
rvm cron setup
With that rvm sets your environment variables in your crontab file
then you have a crontab file having this at the top:
PATH="/usr/local/rvm/gems/ruby-1.9.3-p194/bin:/usr/local/rvm/gems/ruby-1.9.3-p194@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p194/bin:/usr/local/rvm/bin:/usr/local/rvm/gems/ruby-1.9.3-p194/bin:/usr/local/rvm/gems/ruby-1.9.3-p194@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p194/bin:/usr/local/rvm/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/rvm/gems/ruby-1.9.3-p194@global/"
rvm_env_string='ruby-1.9.3-p194'
rvm_path='/usr/local/rvm'
rvm_ruby_string='ruby-1.9.3-p194'
RUBY_VERSION='ruby-1.9.3-p194'
GEM_HOME='/usr/local/rvm/gems/ruby-1.9.3-p194'
GEM_PATH='/usr/local/rvm/gems/ruby-1.9.3-p194:/usr/local/rvm/gems/ruby-1.9.3-p194@global'
MY_RUBY_HOME='/usr/local/rvm/rubies/ruby-1.9.3-p194'
IRBRC='/usr/local/rvm/rubies/ruby-1.9.3-p194/.irbrc'
Then you can stick your crontask beneath it
Source:
http://stackoverflow.com/questions/20672583/requiring-a-ruby-gem-in-ruby-script-breaks-cron-job-execution
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment