Questions tagged [time-utility]

`time` is a command-line utility for running another program and summarizing resource usage

time runs another program and keeps track of how much resources the program has spent. It prints these (normally to stdout) after the program exits.

Basic usage:

time PROGRAM

Additional options (to be specified between time and PROGRAM) allow for redirecting time's output to file (-o filename) optional with appending to that file (-a) and for formatting of the output.

22 questions
111
votes
3 answers

How do I time a specific command?

(The linux equivalent of TimeThis.exe) Something like: timethis wget foo.com Receiving foo.com ... wget foo.com took 3 seconds.
ripper234
  • 31,063
  • 43
  • 82
  • 90
92
votes
5 answers

How to run time on multiple commands AND write the time output to file?

I want to run time command to measure time of several commands. What I want to do is: Use the time command to measure the time it takes to run multiple commands together Write only the time output to a file Write the stderr of all commands I am…
Karel Bílek
  • 1,859
  • 5
  • 20
  • 26
33
votes
5 answers

Make bash use external `time` command rather than shell built-in

How can I make bash use time binary (/usr/bin/time) by default instead of the shell keyword? which time returns /usr/bin/time type time returns time is a shell keyword Running time is obviously executing the shell keyword: $ time real …
David Holdeman
  • 433
  • 4
  • 7
29
votes
6 answers

How to average time commands?

I am timeing some of my commands. Now to average the measures, I'd like to run and time my commands a specified number of times, and get the results with a calculated mean and standard deviation. The result would be like: avgtime -n 100…
Didier Trosset
  • 1,251
  • 1
  • 11
  • 13
29
votes
3 answers

How can I redirect `time` output and command output to the same pipe?

Suppose I have a binary called foo. If I want to redirect the output of foo to some other process bar, I could write ./foo | bar. On the other hand, if I wanted to time foo, and redirect the output of time I could write, time (./foo) | bar. My…
merlin2011
  • 3,855
  • 5
  • 27
  • 36
25
votes
1 answer

Why would the "real" time be much higher than the "user" and "sys" times combined?

I execute and time many commands (i.e. nslookup) through SSH and I collect the total time needed for the implied service to complete (i.e. DNS). So I collect the user and sys time as the real time counts time when my process is blocking which I do…
Muhammad Gelbana
  • 1,583
  • 8
  • 19
  • 25
19
votes
2 answers

Is there something like `time` that also records I/O and CPU?

I can pretty quickly monitor the running time of a process with time: x@y ~ $ time foo real 0m14.299s user 0m4.770s sys 0m0.440s Is there a way I can get the same data for I/O and CPU usage of an argument, recorded to STDOUT?…
John Feminella
  • 557
  • 4
  • 10
14
votes
1 answer

Using the built-in "time" command in bash rather than the external command

Working with the time command, I came across a situation where I should use the built-in time rather than the external GNU time command /usr/bin/time. So, how can I do this? I saw somewhere that using enable and/or command would help, but they…
Ho1
  • 2,552
  • 3
  • 20
  • 25
13
votes
2 answers

Redirect the output of a command in `time command`

I am trying to time something using: /usr/bin/time myCommand However, since /usr/bin/time writes to stderr, if myCommand also writes to stderr, I will get more than just time's output on the stream. What I want to do is, redirect all of myCommand's…
David Doria
  • 253
  • 2
  • 7
9
votes
1 answer

What does `\time`, `t\ime` and `\cd` actually do? (fun with backslashes in shells)

While discussing over the differences between /usr/bin/time and the shell (bash and zsh) built-in time, someone mentioned that one can use \time as a shorthand to get /usr/bin/time. First it seemed like a nice innocent shortcut, but then some…
Jonas Schäfer
  • 1,753
  • 2
  • 14
  • 25
6
votes
1 answer

How do I time a compound command executed in parallel?

How do I time a compound command when most but not all commands executed in parallel: For example the command: comd1 ; comd2 & comd3 & comd4 & comd5 & I tried time (comd1…) But from the output I can speculate that only comd1 was timed because…
forgodsakehold
  • 199
  • 1
  • 1
  • 4
6
votes
1 answer

Log commands execution time

I'd like to log execution time of my commands. Something like this: #!/usr/bin/env bash echo "$@" >> /tmp/times exec 3>&2 (/usr/bin/time -f "%e" "$@" 2>&3) 2>>/tmp/times The problem is that time spawns child process that polluted standard error.…
sevo
  • 1,217
  • 2
  • 10
  • 22
6
votes
2 answers

expand aliases before calling /usr/bin/time

When I use the shell builtin time, I can pass any command I would pass to the shell without time. But when I use the external /usr/bin/time, I cannot pass a shell alias, because /usr/bin/time is naturally not aware of those: $ /usr/bin/time…
gerrit
  • 3,457
  • 6
  • 25
  • 41
2
votes
1 answer

Why full path to /usr/bin/time affects output?

I am running very simple command: [tester@centos-lvm ~]$ time cal > /dev/null real 0m0.001s user 0m0.000s sys 0m0.001s However, if I specify full path to the time executable I get different output: [tester@centos-lvm ~]$ /usr/bin/time…
lesnik
  • 1,341
  • 2
  • 13
  • 20
2
votes
1 answer

Sending `time` command into text file

I want to get the result of time command into a text file but it's not working it only put blank space in the text file. I already tried this commands, A- $ x=`time` $ echo $x > log.txt $ cat log.txt $ B- $ time > log.txt real 0m0.000s user …
Edmhar
  • 395
  • 2
  • 6
  • 16
1
2