]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man1/time.1
shmop.2: wfix
[thirdparty/man-pages.git] / man1 / time.1
CommitLineData
fea681da 1.\" Copyright Andries Brouwer, 2000
35a512d8
MK
2.\" Some fragments of text came from the time-1.7 info file.
3.\" Inspired by kromJx@crosswinds.net.
fea681da 4.\"
b55e2bb3 5.\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
b18188c5 6.\" Distributed under GPL
b55e2bb3 7.\" %%%LICENSE_END
fea681da 8.\"
e194cb7c 9.TH TIME 1 2008-11-14 "" "Linux User's Manual"
fea681da
MK
10.SH NAME
11time \- time a simple command or give resource usage
12.SH SYNOPSIS
13.BI "time [" options "] " command " [" arguments... "] "
14.SH DESCRIPTION
15The
16.B time
17command runs the specified program
18.I command
19with the given arguments.
20When
21.I command
22finishes,
23.B time
e3535a43 24writes a message to standard error giving timing statistics
fea681da
MK
25about this program run.
26These statistics consist of (i) the elapsed real time
27between invocation and termination, (ii) the user CPU time
28(the sum of the
29.I tms_utime
30and
31.I tms_cutime
32values in a
33.I "struct tms"
34as returned by
35.BR times (2)),
36and (iii) the system CPU time (the sum of the
37.I tms_stime
38and
39.I tms_cstime
40values in a
41.I "struct tms"
42as returned by
43.BR times (2)).
e194cb7c 44
a113945f 45Note: some shells (e.g.,
e194cb7c
MK
46.BR bash (1))
47have a built-in
48.B time
49command that provides less functionality than the command described here.
50To access the real command, you may need to specify its pathname
51(something like
52.IR /usr/bin/time ).
e8d07c73 53.SH OPTIONS
fea681da
MK
54.TP
55.B \-p
56When in the POSIX locale, use the precise traditional format
088a639b
MK
57.IP
58.in +4n
31a6818e 59"real %f\enuser %f\ensys %f\en"
088a639b
MK
60.in
61.IP
fea681da
MK
62(with numbers in seconds)
63where the number of decimals in the output for %f is unspecified
64but is sufficient to express the clock tick accuracy, and at least one.
47297adb 65.SH EXIT STATUS
fea681da
MK
66If
67.I command
68was invoked, the exit status is that of
69.IR command .
70Otherwise it is 127 if
71.I command
72could not be found, 126 if it could be found but could not be invoked,
c7094399 73and some other nonzero value (1-125) if something else went wrong.
f5b03186 74.SH ENVIRONMENT
682edefb
MK
75The variables
76.BR LANG ,
66ee0c7e 77.BR LC_ALL ,
682edefb
MK
78.BR LC_CTYPE ,
79.BR LC_MESSAGES ,
80.BR LC_NUMERIC ,
4df883b9 81.BR NLSPATH ,
682edefb
MK
82and
83.B PATH
84are used.
f5b03186
MK
85The last one to search for
86.IR command .
87The remaining ones for the text and formatting of the output.
47297adb 88.SH GNU VERSION
fea681da
MK
89Below a description of the GNU 1.7 version of
90.BR time .
91Disregarding the name of the utility, GNU makes it output lots of
92useful information, not only about time used, but also on other
93resources like memory, I/O and IPC calls (where available).
94The output is formatted using a format string that can be specified
80d26cef
MK
95using the
96.I \-f
97option or the
0daa9e92 98.B TIME
682edefb 99environment variable.
fea681da 100.LP
088a639b
MK
101The default format string is:
102.PP
103.in +4n
fea681da
MK
104%Uuser %Ssystem %Eelapsed %PCPU (%Xtext+%Ddata %Mmax)k
105.br
106%Iinputs+%Ooutputs (%Fmajor+%Rminor)pagefaults %Wswaps
107.br
088a639b 108.in
fea681da 109.LP
80d26cef
MK
110When the
111.I \-p
112option is given the (portable) output format
088a639b
MK
113.PP
114.in +4n
fea681da
MK
115real %e
116.br
117user %U
118.br
119sys %S
120.br
088a639b
MK
121.in
122.PP
fea681da 123is used.
73d8cece 124.SS The format string
fea681da
MK
125The format is interpreted in the usual printf-like way.
126Ordinary characters are directly copied, tab, newline
31a6818e 127and backslash are escaped using \et, \en and \e\e,
fea681da 128a percent sign is represented by %%, and otherwise %
ca7b3c18
MK
129indicates a conversion.
130The program
fea681da
MK
131.B time
132will always add a trailing newline itself.
ca7b3c18
MK
133The conversions follow.
134All of those used by
fea681da
MK
135.BR tcsh (1)
136are supported.
137.LP
138.B "Time"
139.TP
140.B %E
141Elapsed real time (in [hours:]minutes:seconds).
142.TP
143.B %e
144(Not in tcsh.) Elapsed real time (in seconds).
145.TP
146.B %S
147Total number of CPU-seconds that the process spent in kernel mode.
148.TP
149.B %U
150Total number of CPU-seconds that the process spent in user mode.
151.TP
152.B %P
153Percentage of the CPU that this job got, computed as (%U + %S) / %E.
154.LP
155.B "Memory"
156.TP
157.B %M
158Maximum resident set size of the process during its lifetime, in Kbytes.
159.TP
160.B %t
161(Not in tcsh.) Average resident set size of the process, in Kbytes.
162.TP
163.B %K
164Average total (data+stack+text) memory use of the process,
165in Kbytes.
166.TP
167.B %D
168Average size of the process's unshared data area, in Kbytes.
169.TP
170.B %p
171(Not in tcsh.) Average size of the process's unshared stack space, in Kbytes.
172.TP
173.B %X
174Average size of the process's shared text space, in Kbytes.
175.TP
176.B %Z
177(Not in tcsh.) System's page size, in bytes.
178This is a per-system constant, but varies between systems.
179.TP
180.B %F
181Number of major page faults that occurred while the process was running.
182These are faults where the page has to be read in from disk.
183.TP
184.B %R
185Number of minor, or recoverable, page faults.
186These are faults for pages that are not valid but which have
20523df7
MK
187not yet been claimed by other virtual pages.
188Thus the data
fea681da
MK
189in the page is still valid but the system tables must be updated.
190.TP
191.B %W
192Number of times the process was swapped out of main memory.
193.TP
194.B %c
195Number of times the process was context-switched involuntarily
196(because the time slice expired).
197.TP
198.B %w
199Number of waits: times that the program was context-switched voluntarily,
200for instance while waiting for an I/O operation to complete.
201.LP
202.B "I/O"
203.TP
204.B %I
9ee4a2b6 205Number of filesystem inputs by the process.
fea681da
MK
206.TP
207.B %O
9ee4a2b6 208Number of filesystem outputs by the process.
fea681da
MK
209.TP
210.B %r
211Number of socket messages received by the process.
212.TP
213.B %s
214Number of socket messages sent by the process.
215.TP
216.B %k
217Number of signals delivered to the process.
218.TP
219.B %C
76c44d83 220(Not in tcsh.) Name and command-line arguments of the command being timed.
fea681da
MK
221.TP
222.B %x
223(Not in tcsh.) Exit status of the command.
73d8cece 224.SS GNU options
fea681da
MK
225.TP
226.BI "\-f " FORMAT ", \-\-format=" FORMAT
227Specify output format, possibly overriding the format specified
228in the environment variable TIME.
229.TP
230.B "\-p, \-\-portability"
231Use the portable output format.
232.TP
233.BI "\-o " FILE ", \-\-output=" FILE
c6fa0841
MK
234Do not send the results to
235.IR stderr ,
236but overwrite the specified file.
fea681da
MK
237.TP
238.B "\-a, \-\-append"
239(Used together with \-o.) Do not overwrite but append.
240.TP
241.B "\-v, \-\-verbose"
242Give very verbose output about all the program knows about.
73d8cece 243.SS GNU standard options
fea681da
MK
244.TP
245.B "\-\-help"
246Print a usage message on standard output and exit successfully.
247.TP
248.B "\-V, \-\-version"
249Print version information on standard output, then exit successfully.
250.TP
251.B "\-\-"
252Terminate option list.
253.SH BUGS
008f1ecc 254Not all resources are measured by all versions of UNIX,
fea681da
MK
255so some of the values might be reported as zero.
256The present selection was mostly inspired by the data
257provided by 4.2 or 4.3BSD.
258.LP
259GNU time version 1.7 is not yet localized.
260Thus, it does not implement the POSIX requirements.
261.LP
682edefb 262The environment variable
0daa9e92 263.B TIME
682edefb
MK
264was badly chosen.
265It is not unusual for systems like
266.BR autoconf (1)
267or
268.BR make (1)
fea681da 269to use environment variables with the name of a utility to override
ca7b3c18
MK
270the utility to be used.
271Uses like MORE or TIME for options to programs
2d7195b8 272(instead of program pathnames) tend to lead to difficulties.
fea681da 273.LP
80d26cef
MK
274It seems unfortunate that
275.I \-o
276overwrites instead of appends.
277(That is, the
278.I \-a
279option should be the default.)
fea681da
MK
280.LP
281Mail suggestions and bug reports for GNU
282.B time
283to
284.br
4d9b6984 285.I bug\-utils@prep.ai.mit.edu
fea681da
MK
286.br
287Please include the version of
14ee3bff 288.BR time ,
fea681da
MK
289which you can get by running
290.br
4d9b6984 291.I time \-\-version
fea681da
MK
292.br
293and the operating system
294and C compiler you used.
b24f0008
MK
295.\" .SH AUTHORS
296.\" .TP
297.\" .IP "David Keppel"
298.\" Original version
299.\" .IP "David MacKenzie"
300.\" POSIXization, autoconfiscation, GNU getoptization,
301.\" documentation, other bug fixes and improvements.
302.\" .IP "Arne Henrik Juul"
303.\" Helped with portability
304.\" .IP "Francois Pinard"
305.\" Helped with portability
47297adb 306.SH SEE ALSO
fea681da
MK
307.BR tcsh (1),
308.BR times (2),
309.BR wait3 (2)