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

  • your script looks good, does it fail ? – mpapis Feb 12 '12 at 7:59

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
#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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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