summary: directing unix time command output to log

From: Martin Meadows <>
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


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: Dan Lowe <>
From: "Matt M. Morris" <>
From: Darren Spiteri <>
From: Paul Updike <>
From: Dave Werth <>
From: "Chad.Harp" <>
From: "Arthur W. Word Jr." <>
From: "Julian Simpson" <>
From: "Kaiser, Russell" <>
From: Jay Lessert <>
From: Michael Schulte <>
From: Alan B Clegg <>
From: "Kristopher Briscoe" <>
From: Derek Olsen <>
From: "Malloy, Jim" <>
From: Nadya Williams <>
From: "Sanjiv K. Bhatia" <>

sunmanagers mailing list
Received on Fri Sep 14 07:16:01 2001

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:42:25 EST