summary: directing unix time command output to log

From: Martin Meadows <PZXKYS_at_atdva3.atd.gmeds.com>
Date: Fri Sep 14 2001 - 08:15:20 EDT
Wow! I guess the question was too easy. I should have 
known this ... but had forgotten that time was going to stderr ...
Lots of responses! Thanks to everyone for the excellent
assistance!

Marty


Here's the original question:

> I've been running a simple script test today & I wanted
> to dump the output from this script to a log. I ran
> the script and redirected the output to a log. The date
> info (see below) is captured in the log. The result from
> the "time" prefix (see below) on the mv command comes to
> my screen instead of being written to the log. Can someone
> explain how to get the time output to go to my log, too?
> The script, in general, has something like this:
>
>   date
>   time mv /ip4700/A0/scratch/testfile-eds4 /testfile-eds4
>   date
>   time mv /testfile-eds4 /ip4700/A0/scratch/testfile-eds4
>   date  

And here are a couple of the typical responses.

--------------------------------

I think you probably need to redirect the output from stderr also.  When you
redirect using > only stdout is redirected.  To redirect stderr you need
something like this:

  script > log 2>&1

Where 'script' is the script you are running, 'log' is the log file.  '2' is
the handle for stderr and '1' is the handle for stdout so what '2>&1' does
is redirect stderr to stdout. 

---------------------------------


Time sends its output to stderr; you need to redirect stderr.

In csh:    <script>  >&  <file>
In sh:     <script>  > <file> 2>&1    

--------------------------------

I received responses from all these people! Thank you!
Hope I didn't miss anyone!

From: ed.rolison@power.alstom.com
From: Dan Lowe <dan@tangledhelix.com>
From: "Matt M. Morris" <mattm@mattm.net>
From: Darren Spiteri <Darren.Spiteri@affa.gov.au>
From: Paul Updike <updike@msai.mea.com>
From: Dave Werth <iim1dfw@iim.ups.com>
From: "Chad.Harp" <Chad.Harp@yellowcorp.com>
From: "Arthur W. Word Jr." <artword@yahoo.com>
From: "Julian Simpson" <julian_simpson@gmx.co.uk>
From: "Kaiser, Russell" <Kaiser@mail.psc.sc.edu>
From: Jay Lessert <jayl@accelerant.net>
From: Michael Schulte <mike@babbage.cs.umsl.edu>
From: Alan B Clegg <abc@freebsd.org>
From: "Kristopher Briscoe" <krisbriscoe@hotmail.com>
From: Derek Olsen <Derek.Olsen@qsent.com>
From: "Malloy, Jim" <JMalloy@ibasis.net>
From: Nadya Williams <nadya@rai.ucsd.edu>
From: "Sanjiv K. Bhatia" <sanjiv@aryabhat.cs.umsl.edu>
Received on Fri Sep 14 13:15:20 2001

This archive was generated by hypermail 2.1.8 : Wed Mar 23 2016 - 16:32:30 EDT