#!/usr/bin/env ruby # For running rake jobs through cron - only prints output if there is an error # # author mconway # since 8/12/07 RAILS_ROOT = File.expand_path("..", File.dirname(__FILE__)) log = "#{RAILS_ROOT}/log/cron-rake-#{Time.now.tv_sec}.log" begin ident = File.basename(ARGV[-1]).gsub(/\W+/, "_") log = "#{RAILS_ROOT}/log/cron-rake-#{ident}.log" rescue end Dir.chdir(RAILS_ROOT) args = %W{-l #{log} -- bundle exec rake -t} + ARGV system "rvm", "exec", "script/cron-sh", *args