problem with cron and rvm

Discussion in 'Ruby' started by nephish, Sep 23, 2011.

  1. nephish

    nephish Guest

    Hey all,

    I did an rvm install on an ubuntu server. I have a lot of ruby scripts
    that i need to run from cron but cannot seem to get them to work
    correctly.
    It complains about missing gems, etc.. seems as though it is not
    loading the environment correctly. If i run the same script from the
    command line, all is ok.
    Anyone know how to get cron to play nice with rvm? Been all over
    google about it, all the articles i could find did not really explain
    to me how to get cron to use rvm.

    thanks for any tips.
    -shawn
     
    nephish, Sep 23, 2011
    #1
    1. Advertisements

  2. You better look for documentation specific to cron. Cron sets up his
    own environment so the simplest thing you can do is write a wrapper
    shell script which sets all necessary variables the same way as they are
    set in your login shell and then executes Ruby programs. Example

    #!/bin/sh -fe

    FOO=bar
    PATH="abc:${PATH}"
    # more vars...
    export FOO PATH # ...

    exec "$@"


    Kind regards

    robert
     
    Robert Klemme, Sep 23, 2011
    #2
    1. Advertisements

  3. nephish

    nephish Guest

    ok, very cool, thanks
    sk
     
    nephish, Sep 23, 2011
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.