2

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.

Error:

/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-0.9.2.2, 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>'
2
  • 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, 2012 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, 2012 at 17:41

2 Answers 2

3

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.

1
  • Adding the environment variables is what did it for me...thanks @taro
    – Jason Stokes
    Dec 13, 2012 at 15:35
1

Here is the basic documentation for configuring cron:

https://rvm.io/integration/cron/

There is also a new way:

https://github.com/wayneeseguin/rvm/blob/master/help/cron.md

You must log in to answer this question.