Question

In crontab I have:

0,30 * * * * sh /path/to/my/script.sh

and in my script.sh I have:

#!/bin/bash
rvm use 1.9.2@r321
cd /path/to/my/proyect
rails runner rails_script.rb

But it doesn't load the rvm in 1.9.2, It stays on the system setting wich is 1.8.7 in my case.

what should I do to make sure the runner is running under rvm in 1.9.2 with the gemset r321 ?

Was it helpful?

Solution

there are at least 4 ways to make cron working with RVM: https://rvm.io/integration/cron/

personally I prefer the 2. Loading RVM environment files in shell scripts.

OTHER TIPS

I think your problem is: RVM worked only correct in your user shell. Remember after installing rvm you must write somethink like.

'[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"

in your .zshrc or .bashrc

Tell cron with wich user you use rvm because rvm must load as a function and with a user that not load rvm as a function it will not worked and the system ruby version is used automatically. Example:

0,30 * * * * USERNAME bash /path/to/my/script.sh

alternativly you can install rvm as multiuser show at: enter link description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top