Re: Linux measuring elapsed time for a shell command

From: Alan Connor (zzzzzz_at_xxx.yyy)
Date: 05/11/04


Date: Tue, 11 May 2004 19:09:07 GMT

On 11 May 2004 08:27:08 -0700, Peter Grossi <google@grossi.co.uk> wrote:
>
>
> Hi
>
> I am trying to measure the elapsed time for execution of a shell
> command under RedHat 9.0
>
> By putting "time" at the start of the command line, the command is
> executed and the time statistics are reported on screen.
>
> E.g. time dir
>
> The problem is that I need the time statistics to be redirected to a
> file or to a pipe. I have tried various things, but while I can get
> the command output to a file or pipe the time statistics will only go
> to the terminal screen.
>
> Can anybody help?
>
> Thanks
>
> Peter Grossi

Got a workaround, since the bash builtin doesn't seem to have the option
to re-direct the output to a file:

$ script outputfile

$ time command &> /dev/null

$ time command &> /dev/null

Ctrl-d

(to end the script session)

Now the output of everything that went to your terminal is in outputfile,
with what you want and some stuff that you don't :-) The -a option to script
will append-to rather than overwrite outputfile for successive script sessions.

The normal output of the commands are sent to /dev/null to keep
the outputfile as clean as possible.

outputfile can have any name at all, default is "typescript" if
you don't specify a file.

AC

-- 
Pass-List -----> Block-List ----> Challenge-Response
The key to taking control of your mailbox.  Design Parameters:
http://tinyurl.com/2t5kp ||   http://tinyurl.com/3c3ag
Challenge-Response links -- http://tinyurl.com/yrfjb


Relevant Pages

  • Is tcl/tk the solution?
    ... I am relatively new to tcl and am currently trying to establish if it can ... readily satisfy my requirements. ... I have an application written in Fortran, which is passed command line ... ability to type in the outputfile name or select it from a browser. ...
    (comp.lang.tcl)
  • Re: Is tcl/tk the solution?
    ... > readily satisfy my requirements. ... > ability to type in the outputfile name or select it from a browser. ... > should also display the command line and pass the command line to ... proc getFile { ...
    (comp.lang.tcl)
  • [HPADM] SUMMARY Scripting Question
    ... (command; echo $?) ... ret=$(tail -1 outputfile) ... To subscribe/unsubscribe to this list, ...
    (HP-UX-Admin)
  • [HPADM] RE: Scripting Question
    ... (command; echo $?) ... return=`tail -1 outputfile` ... Subject: Scripting Question ...
    (HP-UX-Admin)
  • Linux measuring elapsed time for a shell command
    ... I am trying to measure the elapsed time for execution of a shell ... By putting "time" at the start of the command line, ... executed and the time statistics are reported on screen. ... file or to a pipe. ...
    (comp.os.linux.misc)