Cogs and Levers A blog full of technical stuff

Shebang, Ruby and RVM

I needed to distribute one of my ruby programs to be setup as a job, so I needed to add a shebang to the top of the file. I run my development environment using RVM so I had no idea how to address ruby in the shebang. Then it hit me ..

#!/usr/bin/env ruby

Interestingly, things are a little different when trying to execute a ruby with one of your RVM installed rubies from a cron job. The rvm website has a whole section regarding the topic of cron integration. The command that I passed to successfully execute these jobs needed to be addressed absolutely:

bash -c "/home/user/.rvm/bin/ruby /path/to/script.rb"

Easy.