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