[rvm] Best practice for cron jobs?

335 views
Skip to first unread message

Chad Woolley

unread,
May 4, 2010, 2:10:55 PM5/4/10
to RVM
What's the best practice for invoking ruby scripts usign rvm in a cron
job? Googled a bit, and found one reference, but wondering if there's
some official docs...

Thanks,
-- Chad

--
Please visit http://rvm.beginrescueend.com/ for documentation on rvm.
Please visit https://www.pivotaltracker.com/projects/26822 to see what is being worked on currently.

You received this message because you are subscribed to the Google
Groups "rvm (Ruby Version Manager)" group.
To post to this group, send email to rubyversi...@googlegroups.com
To unsubscribe from this group, send email to
rubyversionmana...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyversionmanager?hl=en

Wayne E. Seguin

unread,
May 4, 2010, 4:10:27 PM5/4/10
to rubyversi...@googlegroups.com
Hi Chad,

Currently that doc page is a story in tracker which I am hoping to get to soon.

The gist of the 'best practice' is to use what is called a wrapper
script, something like:

#!/usr/bin/env bash

source (wherever scripts/rvm is)

rvm X # select a ruby, can use a gemset if you need.

# NOW do the actual task, cd to project root if necessary.
# Note that if you are using a project rvmrc file the cd should
# also take care of the ruby selection above :)

Chad Woolley

unread,
May 5, 2010, 12:33:50 PM5/5/10
to rubyversi...@googlegroups.com
This ended up working for me, I didn't need a wrapper script:

* * * * * myuser bash --login -c 'cd /path/to/myapp && ruby
./script/myscript.rb'

Unfortunately, this same trick doesn't work for monit. I'll open a
separate thread for that...

Thanks,
-- Chad

Wayne E. Seguin

unread,
May 5, 2010, 12:41:54 PM5/5/10
to rubyversi...@googlegroups.com
Yes that 'trick' should work fine for cronjobs and is one of the ones
I use myself.

Nicely done!

~ Wayne
Reply all
Reply to author
Forward
0 new messages