Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > problem with cron and rvm

Reply
Thread Tools

problem with cron and rvm

 
 
nephish
Guest
Posts: n/a
 
      09-23-2011
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
 
Reply With Quote
 
 
 
 
Robert Klemme
Guest
Posts: n/a
 
      09-23-2011
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/
 
Reply With Quote
 
 
 
 
nephish
Guest
Posts: n/a
 
      09-23-2011
On Sep 23, 2:24*pm, Robert Klemme <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Readline problem in ruby 1.9.2 rvm Max Williams Ruby 2 05-08-2011 08:50 PM
Rubygems, RVM and Bundler Confustion lucky Developer Ruby 4 01-05-2011 04:58 PM
rvm and macruby 0.6 Ruohao Li Ruby 0 09-07-2010 06:33 AM
rvm and passenger trouble scott Ruby 0 03-15-2010 10:42 PM
Using both the new rvm Ruby Version Manager, AND multiruby fromZenTest Rick DeNatale Ruby 1 09-06-2009 12:08 AM



Advertisments