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. Advertising

  2. On 23.09.2011 16:57, nephish wrote:
    > 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.


    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

    --
    remember.guy do |as, often| as.you_can - without end
    http://blog.rubybestpractices.com/
     
    Robert Klemme, Sep 23, 2011
    #2
    1. Advertising

  3. nephish

    nephish Guest

    On Sep 23, 2:24 pm, Robert Klemme <> wrote:
    > On 23.09.2011 16:57, nephish wrote:
    >
    > > 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.

    >
    > 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
    >
    > --
    > remember.guy do |as, often| as.you_can - without endhttp://blog.rubybestpractices.com/


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

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rick DeNatale
    Replies:
    1
    Views:
    119
    Wayne E. Seguin
    Sep 6, 2009
  2. scott

    rvm and passenger trouble

    scott, Mar 15, 2010, in forum: Ruby
    Replies:
    0
    Views:
    130
    scott
    Mar 15, 2010
  3. Ruohao Li

    rvm and macruby 0.6

    Ruohao Li, Sep 7, 2010, in forum: Ruby
    Replies:
    0
    Views:
    135
    Ruohao Li
    Sep 7, 2010
  4. lucky Developer

    Rubygems, RVM and Bundler Confustion

    lucky Developer, Jan 5, 2011, in forum: Ruby
    Replies:
    4
    Views:
    164
    Steve Klabnik
    Jan 5, 2011
  5. Max Williams

    Readline problem in ruby 1.9.2 rvm

    Max Williams, May 8, 2011, in forum: Ruby
    Replies:
    2
    Views:
    223
    Max Williams
    May 8, 2011
Loading...

Share This Page