Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to run a backup script on ubuntu. My problem is that I'm trying to do this using the postgres user account that I setup on ubuntu. I believe having this account run the cron jobs is best because it's more of a general account and should I leave the company one day at least they won't have to worry about any cron jobs that might be destroyed if they should destroy my user account on the server, however, I'm having a difficult time getting this working mainly because my postgres user account is not able to see the same ruby environment (I think).

I'm running rvm to control my ruby environment and after adding the direct path to bundle, which is under the rvm install, I'm still getting an error. I'm at a point in which I don't know what else to do.


/home/my_personnel_account/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find bundler (>= 0) amongst [bigdecimal-1.1.0, io-console-0.3, json-1.5.4, minitest-2.5.1, rake-, rdoc-3.9.4] (Gem::LoadError)
from /home/my_personnel_account/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /home/my_personnel_account/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems.rb:1231:in `gem'
from /home/my_personnel_account/.rvm/gems/ruby-1.9.3-p194@global/bin/bundle:22:in `<main>'
share|improve this question

migrated from Dec 22 '12 at 23:47

This question came from our site for professional and enthusiast programmers.

home-based rvm is not good for situations like this. It would be better if you'd install rvm system-wide instead so that all users have the exact same environment by default. – Casper Dec 12 '12 at 16:20
@Casper I was thinking of doing the multi-user rvm install but read that they were security issues with doing that. Not being a security expert that was enough to get me not to go that route. – Jason Stokes Dec 12 '12 at 17:41
up vote 2 down vote accepted

There are two options:

First - add cron job for that user:

crontab -e -u otheruser

Second - use su/sudo to execute command under other account.

sudo -u otheruser command

Make sure you defined all required environment variables - like PATH, GEM_HOME, GEM_PATH.

share|improve this answer
Adding the environment variables is what did it for me...thanks @taro – Jason Stokes Dec 13 '12 at 15:35

Here is the basic documentation for configuring cron:

There is also a new way:

share|improve this answer

You must log in to answer this question.