xref: /freebsd/usr.bin/time/time.1 (revision cb18ba9df52df247198c0f41979090686a0f8403)
1*cb18ba9dSAlexander Ziaee.\"-
2*cb18ba9dSAlexander Ziaee.\" SPDX-License-Identifier: BSD-3-Clause
3*cb18ba9dSAlexander Ziaee.\"
49b50d902SRodney W. Grimes.\" Copyright (c) 1980, 1991, 1993
59b50d902SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
69b50d902SRodney W. Grimes.\"
79b50d902SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
89b50d902SRodney W. Grimes.\" modification, are permitted provided that the following conditions
99b50d902SRodney W. Grimes.\" are met:
109b50d902SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
119b50d902SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
129b50d902SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
139b50d902SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
149b50d902SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
15fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors
169b50d902SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
179b50d902SRodney W. Grimes.\"    without specific prior written permission.
189b50d902SRodney W. Grimes.\"
199b50d902SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
209b50d902SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
219b50d902SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
229b50d902SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
239b50d902SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
249b50d902SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
259b50d902SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
269b50d902SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
279b50d902SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
289b50d902SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
299b50d902SRodney W. Grimes.\" SUCH DAMAGE.
309b50d902SRodney W. Grimes.\"
3150f54dafSFernando Apesteguía.Dd July 7, 2020
329b50d902SRodney W. Grimes.Dt TIME 1
3362500372SRuslan Ermilov.Os
349b50d902SRodney W. Grimes.Sh NAME
359b50d902SRodney W. Grimes.Nm time
369b50d902SRodney W. Grimes.Nd time command execution
379b50d902SRodney W. Grimes.Sh SYNOPSIS
3880c486a4SPhilippe Charnier.Nm
39ea257bd5SDavid E. O'Brien.Op Fl al
40ea257bd5SDavid E. O'Brien.Op Fl h | Fl p
4128f5cafeSDag-Erling Smørgrav.Op Fl o Ar file
423f6c6c91STim J. Robbins.Ar utility Op Ar argument ...
439b50d902SRodney W. Grimes.Sh DESCRIPTION
449b50d902SRodney W. GrimesThe
4580c486a4SPhilippe Charnier.Nm
469b50d902SRodney W. Grimesutility
479b50d902SRodney W. Grimesexecutes and
4851ddbf58STim J. Robbinstimes the specified
4951ddbf58STim J. Robbins.Ar utility .
509b50d902SRodney W. GrimesAfter the
513f6c6c91STim J. Robbins.Ar utility
529b50d902SRodney W. Grimesfinishes,
5380c486a4SPhilippe Charnier.Nm
549b50d902SRodney W. Grimeswrites to the standard error stream,
559b50d902SRodney W. Grimes(in seconds):
569b50d902SRodney W. Grimesthe total time elapsed,
57844338c2SOllivier Robertthe time used to execute the
583f6c6c91STim J. Robbins.Ar utility
59844338c2SOllivier Robertprocess and the time consumed by system overhead.
609b50d902SRodney W. Grimes.Pp
6149b3830cSPhilippe CharnierThe following options are available:
62*cb18ba9dSAlexander Ziaee.Bl -tag -width "-o file"
6328f5cafeSDag-Erling Smørgrav.It Fl a
6428f5cafeSDag-Erling SmørgravIf the
6528f5cafeSDag-Erling Smørgrav.Fl o
6628f5cafeSDag-Erling Smørgravflag is used, append to the specified file rather than overwriting
67e6d3cf26SSheldon Hearnit.
68e6d3cf26SSheldon HearnOtherwise, this option has no effect.
69ea257bd5SDavid E. O'Brien.It Fl h
706a3e8b0aSRuslan ErmilovPrint times in a human friendly format.
716a3e8b0aSRuslan ErmilovTimes are printed in minutes, hours,
726a3e8b0aSRuslan Ermilovetc.\& as appropriate.
739b81ca85SDag-Erling Smørgrav.It Fl l
749b81ca85SDag-Erling SmørgravThe contents of the
759b81ca85SDag-Erling Smørgrav.Em rusage
769b81ca85SDag-Erling Smørgravstructure are printed as well.
77fabfd133SDag-Erling Smørgrav.It Fl o Ar file
7803a22248SPoul-Henning KampWrite the output to
7903a22248SPoul-Henning Kamp.Ar file
806a3e8b0aSRuslan Ermilovinstead of stderr.
816a3e8b0aSRuslan ErmilovIf
8203a22248SPoul-Henning Kamp.Ar file
8328f5cafeSDag-Erling Smørgravexists and the
8428f5cafeSDag-Erling Smørgrav.Fl a
8528f5cafeSDag-Erling Smørgravflag is not specified, the file will be overwritten.
86844338c2SOllivier Robert.It Fl p
87844338c2SOllivier RobertMakes
88844338c2SOllivier Robert.Nm
89844338c2SOllivier Robertoutput POSIX.2 compliant (each time is printed on its own line).
909b50d902SRodney W. Grimes.El
919b50d902SRodney W. Grimes.Pp
92c644db6aSSheldon HearnSome shells may provide a builtin
93c644db6aSSheldon Hearn.Nm
94e6d3cf26SSheldon Hearncommand which is similar or identical to this utility.
95e6d3cf26SSheldon HearnConsult the
96c644db6aSSheldon Hearn.Xr builtin 1
97c644db6aSSheldon Hearnmanual page.
98b6d7073dSPawel Jakub Dawidek.Pp
99b6d7073dSPawel Jakub DawidekIf
100b6d7073dSPawel Jakub Dawidek.Nm
101b6d7073dSPawel Jakub Dawidekreceives a
102b6d7073dSPawel Jakub Dawidek.Dv SIGINFO
103b6d7073dSPawel Jakub Dawidek(see the status argument for
104b6d7073dSPawel Jakub Dawidek.Xr stty 1 )
105b6d7073dSPawel Jakub Dawideksignal, the current time the given command is running will be written to the
106b6d7073dSPawel Jakub Dawidekstandard output.
1078b4f995aSTim J. Robbins.Sh ENVIRONMENT
1088b4f995aSTim J. RobbinsThe
1098b4f995aSTim J. Robbins.Ev PATH
1108b4f995aSTim J. Robbinsenvironment variable is used to locate the requested
1118b4f995aSTim J. Robbins.Ar utility
1128b4f995aSTim J. Robbinsif the name contains no
1138b4f995aSTim J. Robbins.Ql /
1148b4f995aSTim J. Robbinscharacters.
115a866e170SRuslan Ermilov.Sh EXIT STATUS
116844338c2SOllivier RobertIf
1173f6c6c91STim J. Robbins.Ar utility
118e6d3cf26SSheldon Hearncould be timed successfully, its exit status is returned.
119e6d3cf26SSheldon HearnIf
1203f6c6c91STim J. Robbins.Ar utility
121844338c2SOllivier Robertterminated abnormally, a warning message is output to stderr.
122844338c2SOllivier RobertIf the
1233f6c6c91STim J. Robbins.Ar utility
124844338c2SOllivier Robertwas found but could not be run, the exit status is 126.
125844338c2SOllivier RobertIf no
1263f6c6c91STim J. Robbins.Ar utility
127844338c2SOllivier Robertcould be found at all, the exit status is 127.
128844338c2SOllivier RobertIf
129844338c2SOllivier Robert.Nm
130844338c2SOllivier Robertencounters any other error, the exit status is between 1 and 125
131844338c2SOllivier Robertincluded.
13250f54dafSFernando Apesteguía.Sh EXAMPLES
13350f54dafSFernando ApesteguíaTime the execution of
13450f54dafSFernando Apesteguía.Xr ls 1
13550f54dafSFernando Apesteguíaon an empty directory:
13650f54dafSFernando Apesteguía.Bd -literal -offset indent
13750f54dafSFernando Apesteguía$ /usr/bin/time ls
13850f54dafSFernando Apesteguía        0.00 real         0.00 user         0.00 sys
13950f54dafSFernando Apesteguía.Ed
14050f54dafSFernando Apesteguía.Pp
14150f54dafSFernando ApesteguíaTime the execution of the
14250f54dafSFernando Apesteguía.Xr cp 1
14350f54dafSFernando Apesteguíacommand and store the result in the
14450f54dafSFernando Apesteguía.Pa times.txt
14550f54dafSFernando Apesteguíafile.
14650f54dafSFernando ApesteguíaThen execute the command again to make a new copy and add the result to the same
14750f54dafSFernando Apesteguíafile:
14850f54dafSFernando Apesteguía.Bd -literal -offset indent
149*cb18ba9dSAlexander Ziaee$ /usr/bin/time -o times.txt cp source.iso copy1.iso
150*cb18ba9dSAlexander Ziaee$ /usr/bin/time -a -o times.txt cp source.iso copy2.iso
15150f54dafSFernando Apesteguía.Ed
15250f54dafSFernando Apesteguía.Pp
15350f54dafSFernando ApesteguíaThe
15450f54dafSFernando Apesteguía.Pa times.txt
15550f54dafSFernando Apesteguíafile will contain the times of both commands:
15650f54dafSFernando Apesteguía.Bd -literal -offset indent
15750f54dafSFernando Apesteguía$ cat times.txt
15850f54dafSFernando Apesteguía        0.68 real         0.00 user         0.22 sys
15950f54dafSFernando Apesteguía        0.67 real         0.00 user         0.21 sys
16050f54dafSFernando Apesteguía.Ed
16150f54dafSFernando Apesteguía.Pp
16250f54dafSFernando ApesteguíaTime the
16350f54dafSFernando Apesteguía.Xr sleep 1
16450f54dafSFernando Apesteguíacommand and show the results in a human friendly format.
16550f54dafSFernando ApesteguíaShow the contents of the
16650f54dafSFernando Apesteguía.Em rusage
16750f54dafSFernando Apesteguíastructure too:
16850f54dafSFernando Apesteguía.Bd -literal -offset indent
16950f54dafSFernando Apesteguía$ /usr/bin/time -l -h -p sleep 5
17050f54dafSFernando Apesteguíareal 5.01
17150f54dafSFernando Apesteguíauser 0.00
17250f54dafSFernando Apesteguíasys 0.00
17350f54dafSFernando Apesteguía         0  maximum resident set size
17450f54dafSFernando Apesteguía         0  average shared memory size
17550f54dafSFernando Apesteguía         0  average unshared data size
17650f54dafSFernando Apesteguía         0  average unshared stack size
17750f54dafSFernando Apesteguía        80  page reclaims
17850f54dafSFernando Apesteguía         0  page faults
17950f54dafSFernando Apesteguía         0  swaps
18050f54dafSFernando Apesteguía         1  block input operations
18150f54dafSFernando Apesteguía         0  block output operations
18250f54dafSFernando Apesteguía         0  messages sent
18350f54dafSFernando Apesteguía         0  messages received
18450f54dafSFernando Apesteguía         0  signals received
18550f54dafSFernando Apesteguía         3  voluntary context switches
18650f54dafSFernando Apesteguía         0  involuntary context switches
18750f54dafSFernando Apesteguía.Ed
1889b50d902SRodney W. Grimes.Sh SEE ALSO
189c644db6aSSheldon Hearn.Xr builtin 1 ,
1906836c26dSMike Pritchard.Xr csh 1 ,
1916836c26dSMike Pritchard.Xr getrusage 2 ,
1926836c26dSMike Pritchard.Xr wait 2
193844338c2SOllivier Robert.Sh STANDARDS
194844338c2SOllivier RobertThe
195844338c2SOllivier Robert.Nm
196*cb18ba9dSAlexander Ziaeeutility is expected to conform to
197*cb18ba9dSAlexander Ziaee.St -iso9945-2-93
1989b50d902SRodney W. Grimes.Sh HISTORY
1999b50d902SRodney W. GrimesA
2009b50d902SRodney W. Grimes.Nm
20149b3830cSPhilippe Charnierutility appeared in
202780c7a87STim J. Robbins.At v3 .
203