Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6701691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:57:51+00:00 2026-05-26T06:57:51+00:00

I installed and configured RVM roughly following the pattern outlined in the first part

  • 0

I installed and configured RVM roughly following the pattern outlined in the first part of this set of instructions: http://blog.ninjahideout.com/posts/a-guide-to-a-nginx-passenger-and-rvm-server

Basically, this means there is no pre-build system ruby (all ruby installs are RVM-managed) and RVM is installed system-wide instead of attached to a particular user (files at /usr/local/rvm) so all users in the rvm group can access the same rubies with the same installed gems.

One issue with setting up the system this way is that the rvm environment must be set up in a shell session before ruby can be used. For all rvm users, I put this in their .bashrc: source "/usr/local/rvm/scripts/rvm". This works fine for ssh sessions.

The problem comes in play for cron jobs, which don’t execute .bashrc. The rvm script above (/usr/local/rvm/scripts/rvm) is considerably more complicated than setting up a few environment variables, so I’d actually like to run this command prior to every job in the file.

Sure, I could do that manually, like so:

1 2 * * * source "/usr/local/rvm/scripts/rvm"; /do/some/cron/job/1
3 4 * * * source "/usr/local/rvm/scripts/rvm"; /do/some/cron/job/2
5 6 * * * source "/usr/local/rvm/scripts/rvm"; /do/some/cron/job/3
7 8 * * * source "/usr/local/rvm/scripts/rvm"; /do/some/cron/job/4

But I’d prefer to do something like this:

[execute] source "/usr/local/rvm/scripts/rvm"

1 2 * * * /do/some/cron/job/1
3 4 * * * /do/some/cron/job/2
5 6 * * * /do/some/cron/job/3
7 8 * * * /do/some/cron/job/4

Obviously, the above syntax doesn’t work. But, is there some way to get this to work? The cron man pages and documentation were not of much help here. But is there some trick or standard way to achieve this?

If it matters, I’m running Ubuntu 10.10 (Maverick Meerkat).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:57:52+00:00Added an answer on May 26, 2026 at 6:57 am

    You don’t need to write wrappers (following that logic, you might as well write a wrapper to the wrapper). Please keep things simple. All you need to do is configure your cron job to launch a bash shell, and make that bash shell load your environment.

    The shebang line in your script should not refer directly to a ruby executable, but to rvm’s ruby:

    #!/usr/bin/env ruby
    

    This instructs the script to load the environment and run ruby as we would on the command line with rvm loaded.

    On many UNIX derived systems, crontabs can have a configuration section before the actual lines that define the jobs to be run. If this is the case, you would then specify:

    SHELL=/path/to/bash  
    

    This will ensure that the cron job will be spawned from bash. Still, your environment is missing, so to instruct bash to load your environment, you will want to add to the configuration section the following:

    BASH_ENV=/path/to/environment (typically .bash_profile or .bashrc) 
    

    HOME is automatically derived from the /etc/passwd line of the crontab owner, but you can override it.

    HOME=/path/to/home
    

    After this, a cron job might look like this:

    15 14 1 * *     $HOME/rvm_script.rb
    

    What if your crontab doesn’t support the configuration section? Well, you will have to give all the environment directives in one line, with the job itself. For example,

    15 14 1 * * export BASH_ENV=/path/to/environment && /full/path/to/bash -c '/full/path/to/rvm_script.rb'
    

    Full blog post on the subject

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following instructions from http://web2linux.com/installing-rails-3-on-ubuntu-10-04-lucid-lynx/ I get to the following line: rvm install 1.9.2 returns:
I installed and configured a Django/MongoDB like this way ! pip install virtualenv source
I have installed RVM in my ubunut linux box and configured the Rails 3
Following this writeup ... The compiled binary seems to work fine, but the installed
I installed Ruby and then RVM, and then configured Rails. It all works when
I've installed RVM per the instructions at https://rvm.beginrescueend.com/rvm/install/ I logged in as my users
I just installed MOSS 2007 SP2 and configured my site. When I go to
I have installed apache-tomcat-6.0.35-windows-x86 in my system. How can I configure it and set
I am attempting to install Ruby with RVM. I already have Ruby installed, but
I have installed/configured Elmah on my personal SharePoint dev environment and everything works great

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.