|TIME(1)||General Commands Manual||TIME(1)|
NAME¶time - run programs and summarize system resource usage
- [ -apqvV ] [ -f FORMAT ] [
-o FILE ]
DESCRIPTION¶time run the program COMMAND with any given arguments ARG.... When COMMAND finishes, time displays information about resources used by COMMAND (on the standard error output, by default). If COMMAND exits with non-zero status, time displays a warning message and the exit status.
- -o FILE, --output=FILE
- Write the resource use statistics to FILE instead of to the standard error stream. By default, this overwrites the file, destroying the file's previous contents. This option is useful for collecting information on interactive programs and programs that produce output on the standard error stream.
- -a, --append
- Append the resource use information to the output file instead of overwriting it. This option is only useful with the `-o' or `--output' option.
- -f FORMAT, --format FORMAT
- Use FORMAT as the format string that controls the output of time. See the below more information.
- Print a summary of the command line options and exit.
- -p, --portability
- Use the following format string, for conformance with POSIX
- -v, --verbose
- Use the built-in verbose format, which displays each available piece of information on the program's resource use on its own line, with an English description of its meaning.
- Do not report the status of the program even if it is different from zero.
- -V, --version
- Print the version number of time and exit.
FORMATTING THE OUTPUT¶The format string FORMAT controls the contents of the time output. The format string can be set using the `-f' or `--format', `-v' or `--verbose', or `-p' or `--portability' options. If they are not given, but the TIME environment variable is set, its value is used as the format string. Otherwise, a built-in default format is used. The default format is:
%Uuser %Ssystem %Eelapsed %PCPU (%Xtext+%Ddata %Mmax)k
%Iinputs+%Ooutputs (%Fmajor+%Rminor)pagefaults %Wswaps
- A literal `%'.
- Name and command line arguments of the command being timed.
- Average size of the process's unshared data area, in Kilobytes.
- Elapsed real (wall clock) time used by the process, in [hours:]minutes:seconds.
- Number of major, or I/O-requiring, page faults that occurred while the process was running. These are faults where the page has actually migrated out of primary memory.
- Number of file system inputs by the process.
- Average total (data+stack+text) memory use of the process, in Kilobytes.
- Maximum resident set size of the process during its lifetime, in Kilobytes.
- Number of file system outputs by the process.
- Percentage of the CPU that this job got. This is just user + system times divided by the total running time. It also prints a percentage sign.
- Number of minor, or recoverable, page faults. These are pages that are not valid (so they fault) but which have not yet been claimed by other virtual pages. Thus the data in the page is still valid but the system tables must be updated.
- Total number of CPU-seconds used by the system on behalf of the process (in kernel mode), in seconds.
- Total number of CPU-seconds that the process used directly (in user mode), in seconds.
- Number of times the process was swapped out of main memory.
- Average amount of shared text in the process, in Kilobytes.
- System's page size, in bytes. This is a per-system constant, but varies between systems.
- Number of times the process was context-switched involuntarily (because the time slice expired).
- Elapsed real (wall clock) time used by the process, in seconds.
- Number of signals delivered to the process.
- Average unshared stack size of the process, in Kilobytes.
- Number of socket messages received by the process.
- Number of socket messages sent by the process.
- Average resident set size of the process, in Kilobytes.
- Number of times that the program was context-switched voluntarily, for instance while waiting for an I/O operation to complete.
- Exit status of the command.
EXAMPLES¶To run the command `wc /etc/hosts' and show the default information:
time wc /etc/hosts
time -f "\t%E real,\t%U user,\t%S sys" ls -Fs
export TIME="\t%E,\t%k" # If using bash or ksh
setenv TIME "\t%E,\t%k" # If using csh or tcsh
time -a -o log emacs bork
/usr/bin/time wc /etc/hosts
ACCURACY¶The elapsed time is not collected atomically with the execution of the program; as a result, in bizarre circumstances (if the time command gets stopped or swapped out in between when the program being timed exits and when time calculates how long it took to run), it could be much larger than the actual execution time.
DIAGNOSTICS¶The time command returns when the program exits, stops, or is terminated by a signal. If the program exited normally, the return value of time is the return value of the program it executed and measured. Otherwise, the return value is 128 plus the number of the signal which caused the program to stop or terminate.
AUTHOR¶time was written by David MacKenzie. This man page was added by Dirk Eddelbuettel <firstname.lastname@example.org>, the Debian GNU/Linux maintainer, for use by the Debian GNU/Linux distribution but may of course be used by others.
SEE ALSO¶tcsh(1), printf(3)