Daily cron job to check for outdated Ruby gems via RVM

I am running Apache + Passenger on a server which is set to use the global RVM gemset for all vhosts. Here's a simple cron script to check for gem updates.

Check which RVM gemset you are using:

$ rvm current
ruby-1.9.3-p392@global

# search through apache conf to find RVM environment path:
$ grep -i passenger /etc/apache2/apache2.conf
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p392@global/gems/passenger-3.0.19/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p392@global/gems/passenger-3.0.19
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p392@global/ruby

Create a new script: (ex: /root/scripts/crongemoutdated.sh)

#!/usr/bin/env bash
source /usr/local/rvm/environments/ruby-1.9.3-p392@global
gem outdated

Add cron job:

$ sudo crontab -e
1 1 * * * /root/scripts/cron_gem_outdated.sh