1time(1)                          User Commands                         time(1)
2
3
4

NAME

6       time - time a simple command
7

SYNOPSIS

9       time [-p] utility [argument]...
10
11

DESCRIPTION

13       The  time  utility  invokes utility operand with argument, and writes a
14       message to standard error that lists timing statistics for utility. The
15       message includes the following information:
16
17           o      The  elapsed  (real)  time between invocation of utility and
18                  its termination.
19
20           o      The User CPU time, equivalent to the sum  of  the  tms_utime
21                  and  tms_cutime fields returned by the times(2) function for
22                  the process in which utility is executed.
23
24           o      The System CPU time, equivalent to the sum of the  tms_stime
25                  and  tms_cstime  fields returned by the times() function for
26                  the process in which utility is executed.
27
28
29       When time is used as part of a pipeline, the times reported are unspec‐
30       ified,  except when it is the sole command within a grouping command in
31       that pipeline. For example, the commands on the left  are  unspecified;
32       those on the right report on utilities a and c, respectively:
33
34         time a | b | c      { time a } | b | c
35         a | b | time c      a | b | (time c)
36
37

OPTIONS

39       The following option is supported:
40
41       -p     Writes the timing output to standard error in the following for‐
42              mat:
43
44                real %f\nuser %f\nsys %f\n < real seconds>, <user seconds>,
45                <system seconds>
46
47
48
49

OPERANDS

51       The following operands are supported:
52
53       utility      The name of the utility that is to be invoked.
54
55
56       argument     Any string to be supplied as  an  argument  when  invoking
57                    utility.
58
59

USAGE

61       The  time  utility  returns  exit status 127 if an error occurs so that
62       applications can distinguish "failure to find a utility" from  "invoked
63       utility  exited  with  an  error  indication." The value 127 was chosen
64       because it is not commonly used for other meanings. Most utilities  use
65       small values for "normal error conditions" and the values above 128 can
66       be confused with termination due to receipt of a signal. The value  126
67       was  chosen  in  a similar manner to indicate that the utility could be
68       found, but not invoked.
69

EXAMPLES

71       Example 1 Using the time command
72
73
74       It is frequently desirable to apply time to pipelines or lists of  com‐
75       mands.  This  can  be  done by placing pipelines and command lists in a
76       single file. This single file can then be invoked as a utility, and the
77       time applies to everything in the file.
78
79
80
81       Alternatively,  the  following  command  can be used to apply time to a
82       complex command:
83
84
85         example% time sh -c 'complex-command-line'
86
87
88
89       Example 2 Using time in the csh shell
90
91
92       The following two examples show the differences between the csh version
93       of  time  and  the version in /usr/bin/time. These examples assume that
94       csh is the shell in use.
95
96
97         example% time find / -name csh.1 -print
98         /usr/share/man/man1/csh.1
99         95.0u 692.0s 1:17:52 16% 0+0k 0+0io 0pf+0w
100
101
102
103
104       See csh(1) for an explanation of the format of time output.
105
106
107         example% /usr/bin/time find / -name csh.1 -print
108         /usr/share/man/man1/csh.1
109         real  1:23:31.5
110         user     1:33.2
111         sys     11:28.2
112
113
114

ENVIRONMENT VARIABLES

116       See environ(5) for descriptions of the following environment  variables
117       that affect the execution of time: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES,
118       LC_NUMERIC,  NLSPATH, and PATH.
119

EXIT STATUS

121       If utility is invoked, the exit status of time will be the exit  status
122       of  utility. Otherwise, the time utility will exit with one of the fol‐
123       lowing values:
124
125       1−125        An error occurred in the time utility.
126
127
128       126          utility was found but could not be invoked.
129
130
131       127          utility could not be found.
132
133

ATTRIBUTES

135       See attributes(5) for descriptions of the following attributes:
136
137
138
139
140       ┌─────────────────────────────┬─────────────────────────────┐
141       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
142       ├─────────────────────────────┼─────────────────────────────┤
143       │Availability                 │SUNWcsu                      │
144       ├─────────────────────────────┼─────────────────────────────┤
145       │Interface Stability          │Standard                     │
146       └─────────────────────────────┴─────────────────────────────┘
147

SEE ALSO

149       csh(1), shell_builtins(1),  timex(1),  times(2),  attributes(5),  envi‐
150       ron(5), standards(5)
151

NOTES

153       When  the time command is run on a multiprocessor machine, the total of
154       the values printed for user and sys can exceed real. This  is   because
155       on  a  multiprocessor machine it is possible to divide the task between
156       the various processors.
157
158
159       When the command being timed is interrupted,  the  timing  values  dis‐
160       played may not always be accurate.
161

BUGS

163       Elapsed  time  is  accurate to the second, while the CPU times are mea‐
164       sured to the 100th second. Thus the sum of the CPU times can be up to a
165       second larger than the elapsed time.
166
167
168
169SunOS 5.11                        1 Feb 1995                           time(1)
Impressum