We need a certain gem application run on a cron schedule, so we have a dedicated user set up to run this gem.
We are currently using ruby 1.9.2
[jobrunner@test-load] rvm list
rvm rubies
ruby-1.8.7-p299 [ x86_64 ]
ruby-1.9.2-p180 [ x86_64 ]
=* ruby-1.9.2-p290 [ x86_64 ]
ruby-1.9.3-p125 [ x86_64 ]
ruby-1.9.3-p374 [ x86_64 ]
ruby-1.9.3-p392 [ x86_64 ]
ruby-1.9.3-p448 [ x86_64 ]
ruby-2.0.0-p247 [ x86_64 ]
# => - current
# =* - current && default
# * - default
Unfortunately I need this user to run on ruby 1.9.3. Changing the default ruby version is not an option because rvm is installed system wide (/usr/local/rvm/bin/rvm
) and other users on the system rely on 1.9.2.
If I were in an interactive session, it would be as simple as
rvm use 1.9.3
However, it appears I can't use rvm use
in a non-interactive session (i.e. in the crontab). (I tried it by sticking that in my bashrc
file and telling cron to look at my bashrc
file. I ended up forkbombing myself..)
How do I get my crontab using a specific version of ruby via rvm?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…