Friday, December 30, 2011

RVM and CRON with ruby PADRINO

When cron runs a job, the job has very little environment. In my installation, I use RVM to switch between different versions of ruby, and so trying to run any sort of cron job is difficult.

My recommendation is that you start out using a shell script which executes your ruby process. Here's one that works for me:

#!/bin/sh
. /usr/bin/rvm > /dev/null
rvm use ruby-1.9.3-p0

cd /wherever
export PADRINO_ENV=production
/usr/bin/time ./import-noc-events.rb
exit 0