#!/usr/bin/env ruby # For running 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-runner-#{Time.now.tv_sec}.log" begin ident = File.basename(ARGV[-1]).gsub(/\W+/, "_") log = "#{RAILS_ROOT}/log/cron-runner-#{ident}.log" rescue end Dir.chdir(RAILS_ROOT) args = %W{-e -l #{log} -- RAILS_RUNNER} + ARGV system "script/cron-sh", *args