Move everything from /var/adm to /var/log
[unleashed.git] / share / man / man1 / time.1
blob0538d293ccbff2188114187da4da87596ed08c4d
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
44 .\" Portions Copyright (c) 1995, Sun Microsystems, Inc.  All Rights Reserved
45 .\"
46 .TH TIME 1 "Feb 1, 1995"
47 .SH NAME
48 time \- time a simple command
49 .SH SYNOPSIS
50 .LP
51 .nf
52 \fBtime\fR [\fB-p\fR] \fIutility\fR [\fIargument\fR]...
53 .fi
55 .SH DESCRIPTION
56 .sp
57 .LP
58 The \fBtime\fR utility invokes \fIutility\fR operand with \fIargument\fR, and
59 writes a message to standard error that lists timing statistics for
60 \fIutility\fR. The message includes the following information:
61 .RS +4
62 .TP
63 .ie t \(bu
64 .el o
65 The elapsed (real) time between invocation of \fIutility\fR and its
66 termination.
67 .RE
68 .RS +4
69 .TP
70 .ie t \(bu
71 .el o
72 The User \fBCPU\fR time, equivalent to the sum of the \fItms_utime\fR and
73 \fItms_cutime\fR fields returned by the \fBtimes\fR(2) function for the process
74 in which \fIutility\fR is executed.
75 .RE
76 .RS +4
77 .TP
78 .ie t \(bu
79 .el o
80 The System \fBCPU\fR time, equivalent to the sum of the \fItms_stime\fR and
81 \fItms_cstime\fR fields returned by the \fBtimes()\fR function for the process
82 in which \fIutility\fR is executed.
83 .RE
84 .sp
85 .LP
86 When \fBtime\fR is used as part of a pipeline, the times reported are
87 unspecified, except when it is the sole command within a grouping command in
88 that pipeline. For example, the commands on the left are unspecified; those on
89 the right report on utilities \fBa\fR and \fBc\fR, respectively:
90 .sp
91 .in +2
92 .nf
93 time a | b | c          { time a } | b | c
94 a | b | time c          a | b | (time c)
95 .fi
96 .in -2
98 .SH OPTIONS
99 .sp
101 The following option is supported:
103 .ne 2
105 \fB\fB-p\fR \fR
107 .RS 7n
108 Writes the timing output to standard error in the following format:
110 .in +2
112 real %f\enuser %f\ensys %f\en < \fIreal seconds\fR>, <\fIuser seconds\fR>,
113 <\fIsystem seconds\fR>
115 .in -2
120 .SH OPERANDS
123 The following operands are supported:
125 .ne 2
127 \fB\fIutility\fR \fR
129 .RS 13n
130 The name of the utility that is to be invoked.
134 .ne 2
136 \fB\fIargument\fR \fR
138 .RS 13n
139 Any string to be supplied as an argument when invoking \fIutility\fR.
142 .SH USAGE
145 The \fBtime\fR utility returns exit status \fB127\fR if an error occurs so that
146 applications can distinguish "failure to find a utility" from "invoked utility
147 exited with an error indication." The value \fB127\fR was chosen because it is
148 not commonly used for other meanings. Most utilities use small values for
149 "normal error conditions" and the values above \fB128\fR can be confused with
150 termination due to receipt of a signal. The value \fB126\fR was chosen in a
151 similar manner to indicate that the utility could be found, but not invoked.
152 .SH EXAMPLES
154 \fBExample 1 \fRUsing the time command
157 It is frequently desirable to apply \fBtime\fR to pipelines or lists of
158 commands. This can be done by placing pipelines and command lists in a single
159 file. This single file can then be invoked as a utility, and the \fBtime\fR
160 applies to everything in the file.
164 Alternatively, the following command can be used to apply \fBtime\fR to a
165 complex command:
168 .in +2
170 example% \fBtime sh -c 'complex-command-line'\fR
172 .in -2
176 \fBExample 2 \fRUsing time in the csh shell
179 The following two examples show the differences between the \fBcsh\fR version
180 of \fBtime\fR and the version in \fB/usr/bin/time\fR. These examples assume
181 that \fBcsh\fR is the shell in use.
184 .in +2
186 example% \fBtime find / -name csh.1 -print
187 /usr/share/man/man1/csh.1\fR
188 95.0u 692.0s 1:17:52 16% 0+0k 0+0io 0pf+0w
190 .in -2
195 See \fBcsh\fR(1) for an explanation of the format of \fBtime\fR output.
198 .in +2
200 example% \fB/usr/bin/time find / -name csh.1 -print
201 /usr/share/man/man1/csh.1\fR
202 real  1:23:31.5
203 user     1:33.2
204 sys     11:28.2
206 .in -2
209 .SH ENVIRONMENT VARIABLES
212 See \fBenviron\fR(5) for descriptions of the following environment variables
213 that affect the execution of \fBtime\fR: \fBLANG\fR, \fBLC_ALL\fR,
214 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, \fBLC_NUMERIC\fR,  \fBNLSPATH\fR, and
215 \fBPATH\fR.
216 .SH EXIT STATUS
219 If \fIutility\fR is invoked, the exit status of \fBtime\fR will be the exit
220 status of \fIutility\fR. Otherwise, the \fBtime\fR utility will exit with one
221 of the following values:
223 .ne 2
225 \fB\fB1\(mi125\fR \fR
227 .RS 13n
228 An error occurred in the \fBtime\fR utility.
232 .ne 2
234 \fB\fB126\fR \fR
236 .RS 13n
237 \fIutility\fR was found but could not be invoked.
241 .ne 2
243 \fB\fB127\fR \fR
245 .RS 13n
246 \fIutility\fR could not be found.
249 .SH ATTRIBUTES
252 See \fBattributes\fR(5) for descriptions of the following attributes:
257 box;
258 c | c
259 l | l .
260 ATTRIBUTE TYPE  ATTRIBUTE VALUE
262 Interface Stability     Standard
265 .SH SEE ALSO
268 \fBcsh\fR(1), \fBshell_builtins\fR(1), \fBtimex\fR(1), \fBtimes\fR(2),
269 \fBattributes\fR(5), \fBenviron\fR(5), \fBstandards\fR(5)
270 .SH NOTES
273 When the time command is run on a multiprocessor machine, the total of the
274 values printed for \fBuser\fR and \fBsys\fR can exceed \fBreal\fR. This is
275 because on a multiprocessor machine it is possible to divide the task between
276 the various processors.
279 When the command being timed is interrupted, the timing values displayed may
280 not always be accurate.
281 .SH BUGS
284 Elapsed time is accurate to the second, while the \fBCPU\fR times are measured
285 to the 100th second. Thus the sum of the \fBCPU\fR times can be up to a second
286 larger than the elapsed time.