Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to make RVM and fcron work together. Apparently fcron does not read directly or indirectly any sort of env variables. Which makes RVM futile and scripts fail.

I have this script which works with RVM ruby-1.9.3, rvm-gems etc. Although I tried implementing the following wrapper:

#!/usr/bin/env bash
set -x -v

# load rvm ruby
source /home/user/.rvm/environments/ruby-1.9.3-p0

#ruby /usr/local/bin/morula -s hakmem update
/home/user/.rvm/rubies/ruby-1.9.3-p0/bin/ruby /usr/local/bin/script -s username update

My fcrontab just executes the '/home/user/test.sh' (the above script).

I've tried putting SHELL, GEM_HOME, PATH, LANG and other variables on fcrontab -e but nothing worked so far. Any ideas are welcome.

Best regards

share|improve this question
    
your script looks good, does it fail ? –  mpapis Feb 12 '12 at 7:59
add comment

1 Answer 1

up vote 0 down vote accepted

The above script did not work. I had to set much additional variables on the crontab for this to work. On FreeBSD I use the following:

# etc/crontab - crontab for FreeBSD
PATH=/home/www/atma/.rvm/bin:$PATH
LANG=en_US.UTF-8
#GEM_HOME=/home/www/atma/.rvm/gems/ruby-1.9.3-p125:/home/www/atma/.rvm/gems/ruby-1.9.3-p125@global
GEM_HOME=/home/www/atma/.gems
SHELL=/usr/local/bin/bash
#minute hour    mday    month   wday    who command
30 10 * * * /home/www/atma/.rvm/rubies/ruby-1.9.3-p125/bin/ruby /home/www/atma/opt/scripts/pharmanights
#> /dev/null 2>&1

Here is a detailed blogpost about RVM + fcron http://www.convalesco.org/index.php/archives/2385

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.