#!/usr/bin/ruby
start_time = Time.now
file_to_execute = 'ruby1.9 ./long_app.rb'
seconds_required = 5 # must run for at least 5 seconds to be logged
buffer = `#{file_to_execute} 2>&1`
File.open( 'my.log', 'a' ).write buffer unless Time.now.to_i - start_time.to_i < seconds_required
Would a bash script be simple to do this? All I have right now is printing the entire output to a file, and I just want to print if it's a high time delay.