1.\" Copyright (c) 1980, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. Neither the name of the University nor the names of its contributors 13.\" may be used to endorse or promote products derived from this software 14.\" without specific prior written permission. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26.\" SUCH DAMAGE. 27.\" 28.\" @(#)time.1 8.1 (Berkeley) 6/6/93 29.\" 30.Dd July 7, 2020 31.Dt TIME 1 32.Os 33.Sh NAME 34.Nm time 35.Nd time command execution 36.Sh SYNOPSIS 37.Nm 38.Op Fl al 39.Op Fl h | Fl p 40.Op Fl o Ar file 41.Ar utility Op Ar argument ... 42.Sh DESCRIPTION 43The 44.Nm 45utility 46executes and 47times the specified 48.Ar utility . 49After the 50.Ar utility 51finishes, 52.Nm 53writes to the standard error stream, 54(in seconds): 55the total time elapsed, 56the time used to execute the 57.Ar utility 58process and the time consumed by system overhead. 59.Pp 60The following options are available: 61.Bl -tag -width indent 62.It Fl a 63If the 64.Fl o 65flag is used, append to the specified file rather than overwriting 66it. 67Otherwise, this option has no effect. 68.It Fl h 69Print times in a human friendly format. 70Times are printed in minutes, hours, 71etc.\& as appropriate. 72.It Fl l 73The contents of the 74.Em rusage 75structure are printed as well. 76.It Fl o Ar file 77Write the output to 78.Ar file 79instead of stderr. 80If 81.Ar file 82exists and the 83.Fl a 84flag is not specified, the file will be overwritten. 85.It Fl p 86Makes 87.Nm 88output POSIX.2 compliant (each time is printed on its own line). 89.El 90.Pp 91Some shells may provide a builtin 92.Nm 93command which is similar or identical to this utility. 94Consult the 95.Xr builtin 1 96manual page. 97.Pp 98If 99.Nm 100receives a 101.Dv SIGINFO 102(see the status argument for 103.Xr stty 1 ) 104signal, the current time the given command is running will be written to the 105standard output. 106.Sh ENVIRONMENT 107The 108.Ev PATH 109environment variable is used to locate the requested 110.Ar utility 111if the name contains no 112.Ql / 113characters. 114.Sh EXIT STATUS 115If 116.Ar utility 117could be timed successfully, its exit status is returned. 118If 119.Ar utility 120terminated abnormally, a warning message is output to stderr. 121If the 122.Ar utility 123was found but could not be run, the exit status is 126. 124If no 125.Ar utility 126could be found at all, the exit status is 127. 127If 128.Nm 129encounters any other error, the exit status is between 1 and 125 130included. 131.Sh EXAMPLES 132Time the execution of 133.Xr ls 1 134on an empty directory: 135.Bd -literal -offset indent 136$ /usr/bin/time ls 137 0.00 real 0.00 user 0.00 sys 138.Ed 139.Pp 140Time the execution of the 141.Xr cp 1 142command and store the result in the 143.Pa times.txt 144file. 145Then execute the command again to make a new copy and add the result to the same 146file: 147.Bd -literal -offset indent 148$ /usr/bin/time -o times.txt cp FreeBSD-12.1-RELEASE-amd64-bootonly.iso copy1.iso 149$ /usr/bin/time -a -o times.txt cp FreeBSD-12.1-RELEASE-amd64-bootonly.iso copy2.iso 150.Ed 151.Pp 152The 153.Pa times.txt 154file will contain the times of both commands: 155.Bd -literal -offset indent 156$ cat times.txt 157 0.68 real 0.00 user 0.22 sys 158 0.67 real 0.00 user 0.21 sys 159.Ed 160.Pp 161Time the 162.Xr sleep 1 163command and show the results in a human friendly format. 164Show the contents of the 165.Em rusage 166structure too: 167.Bd -literal -offset indent 168$ /usr/bin/time -l -h -p sleep 5 169real 5.01 170user 0.00 171sys 0.00 172 0 maximum resident set size 173 0 average shared memory size 174 0 average unshared data size 175 0 average unshared stack size 176 80 page reclaims 177 0 page faults 178 0 swaps 179 1 block input operations 180 0 block output operations 181 0 messages sent 182 0 messages received 183 0 signals received 184 3 voluntary context switches 185 0 involuntary context switches 186.Ed 187.Sh SEE ALSO 188.Xr builtin 1 , 189.Xr csh 1 , 190.Xr getrusage 2 , 191.Xr wait 2 192.Sh STANDARDS 193The 194.Nm 195utility is expected to conform to ISO/IEC 9945-2:1993 (``POSIX''). 196.Sh HISTORY 197A 198.Nm 199utility appeared in 200.At v3 . 201