time(1) | time a simple command or give resource usage |
time(1P, 1p) | time a simple command |
time(1) | General Commands Manual | time(1) |
time - time a simple command or give resource usage
time [option ...] command [argument ...]
The time command runs the specified program command with the given arguments. When command finishes, time writes a message to standard error giving timing statistics about this program run. These statistics consist of (i) the elapsed real time between invocation and termination, (ii) the user CPU time (the sum of the tms_utime and tms_cutime values in a struct tms as returned by times(2)), and (iii) the system CPU time (the sum of the tms_stime and tms_cstime values in a struct tms as returned by times(2)).
Note: some shells (e.g., bash(1)) have a built-in time command that provides similar information on the usage of time and possibly other resources. To access the real command, you may need to specify its pathname (something like /usr/bin/time).
"real %f\nuser %f\nsys %f\n"
If command was invoked, the exit status is that of command. Otherwise, it is 127 if command could not be found, 126 if it could be found but could not be invoked, and some other nonzero value (1–125) if something else went wrong.
The variables LANG, LC_ALL, LC_CTYPE, LC_MESSAGES, LC_NUMERIC, and NLSPATH are used for the text and formatting of the output. PATH is used to search for command.
Below a description of the GNU 1.7 version of time. Disregarding the name of the utility, GNU makes it output lots of useful information, not only about time used, but also on other resources like memory, I/O and IPC calls (where available). The output is formatted using a format string that can be specified using the -f option or the TIME environment variable.
The default format string is:
%Uuser %Ssystem %Eelapsed %PCPU (%Xtext+%Ddata %Mmax)k %Iinputs+%Ooutputs (%Fmajor+%Rminor)pagefaults %Wswaps
When the -p option is given, the (portable) output format is used:
real %e user %U sys %S
The format is interpreted in the usual printf-like way. Ordinary characters are directly copied, tab, newline, and backslash are escaped using \t, \n, and \\, a percent sign is represented by %%, and otherwise % indicates a conversion. The program time will always add a trailing newline itself. The conversions follow. All of those used by tcsh(1) are supported.
Time
Memory
I/O
Not all resources are measured by all versions of UNIX, so some of the values might be reported as zero. The present selection was mostly inspired by the data provided by 4.2 or 4.3BSD.
GNU time version 1.7 is not yet localized. Thus, it does not implement the POSIX requirements.
The environment variable TIME was badly chosen. It is not unusual for systems like autoconf(1) or make(1) to use environment variables with the name of a utility to override the utility to be used. Uses like MORE or TIME for options to programs (instead of program pathnames) tend to lead to difficulties.
It seems unfortunate that -o overwrites instead of appends. (That is, the -a option should be the default.)
Mail suggestions and bug reports for GNU time to bug-time@gnu.org. Please include the version of time, which you can get by running
time --version
and the operating system and C compiler you used.
bash(1), tcsh(1), times(2), wait3(2)
2023-07-30 | Linux man-pages 6.05.01 |