output rediection for 'time' command

output rediection for 'time' command

Post by David » Fri, 19 Jun 1992 17:25:09



I want to time a command and redirect the outputs of both commands to a file.
        time my_command > out
        0.2u 0.3s 0:00 58% 0+280k 13+0io 11pf+0w
How do I do that? Thanks in advance.

Dave
                        \\|//


University of Melbourne  \_/     |  uunet    : uunet!munnari!mullian!dtau

 
 
 

output rediection for 'time' command

Post by S. Spencer S » Sat, 20 Jun 1992 03:43:37



>I want to time a command and redirect the outputs of both commands to a file.
>    time my_command > out
>    0.2u 0.3s 0:00 58% 0+280k 13+0io 11pf+0w
>How do I do that? Thanks in advance.

From experimentation and a bit of what I hope is educated guessing, I'd
say there are two ways for you to do this.

If the 'time' you are using is a shell built-in, then since the shell is
printing it out and not a running process, you can't just redirect it.  So,
what you do is put it in a sub-shell and redirect THAT output.  e.g.

(time ls) >file_listing 2>time_info

The subshell will print out the time output, but to the parent shell
this is the subshell's stderr.

Or, you could use an executable instead of the shell built-in:

/bin/time ls >file_listing 2>time_info

----------- The opinions expressed in this article are solely mine. -----------
<Insert lame attempt at disclaimer humor>

If you're not part of the solution, you're part of the precipitate.  [fortune]

 
 
 

output rediection for 'time' command

Post by David » Sat, 20 Jun 1992 09:55:37


(time my_command) > out works fine for me. Thanks to those people who promptly
replied.

Dave
                        \\|//


University of Melbourne  \_/     |  uunet    : uunet!munnari!mullian!dtau

 
 
 

1. How do I re-format the 'time' command's output?

I've been trying to use the 'time' command built-into tcsh to time
processes.  Although it reports the time used correctly and all, I'm trying
to following the instructions in the man page to have it also display the
amount of memory used by the process.

From the tcsh man page:
  time    If set to a number, then the time builtin (q.v.) executes auto-
            matically  after  each  command which takes more than that many
            CPU seconds.  If there is a second word, it is used as a format
            string  for  the  output of the time builtin. (u) The following
            sequences may be used in the format string:
                    ...
            %X  The average amount in (shared) text space used in Kbytes.
            %D  The average amount in (unshared) data/stack space  used in
                   Kbytes.
            %K  The total space used (%X + %D) in Kbytes.
            %M  The  maximum  memory  the process had in use at any time in
                   Kbytes.
                     ...

My problem is that I have no idea how to format this time variable.  I've
tried just about everything I can think of (and then even some stuff that
others have suggested), but to no avail.  I just can't seem to get the
format string to change at all  - not in the slightest.

Has anyone else modified the output of this command before?  Do you know how
I can determine the total/max amount of memory used by a process?  In theory
the time
command does just that - I just can't get it to work.  And 'top' isn't an
option.

Thanks!

Eric


2. unusal setup problem

3. how to change the default output of 'time' command

4. OSR5.0.4c: Netconfig changes don't take

5. About the 'TIME' header of the 'ps' command

6. dosemu & segmentation fault

7. can't redirect output of "time" command

8. Why isn't there an MS Linux?

9. 'last' command doesn't show complete login times

10. 'time' command doesn't display memory usage

11. Piping results of a 'find' command to a 'mv' command...

12. Odd 'w', 'who' and 'tty' output

13. what does the output of 'time' (unix) mean?