{"id":5713,"date":"2022-12-20T18:57:28","date_gmt":"2022-12-20T21:57:28","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/time-man1p\/"},"modified":"2022-12-20T18:57:28","modified_gmt":"2022-12-20T21:57:28","slug":"time-man1p","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/time-man1p\/","title":{"rendered":"TIME (man1p)"},"content":{"rendered":"<h1 align=\"center\">TIME<\/h1>\n<p> <a href=\"#PROLOG\">PROLOG<\/a><br \/> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#OPTIONS\">OPTIONS<\/a><br \/> <a href=\"#OPERANDS\">OPERANDS<\/a><br \/> <a href=\"#STDIN\">STDIN<\/a><br \/> <a href=\"#INPUT FILES\">INPUT FILES<\/a><br \/> <a href=\"#ENVIRONMENT VARIABLES\">ENVIRONMENT VARIABLES<\/a><br \/> <a href=\"#ASYNCHRONOUS EVENTS\">ASYNCHRONOUS EVENTS<\/a><br \/> <a href=\"#STDOUT\">STDOUT<\/a><br \/> <a href=\"#STDERR\">STDERR<\/a><br \/> <a href=\"#OUTPUT FILES\">OUTPUT FILES<\/a><br \/> <a href=\"#EXTENDED DESCRIPTION\">EXTENDED DESCRIPTION<\/a><br \/> <a href=\"#EXIT STATUS\">EXIT STATUS<\/a><br \/> <a href=\"#CONSEQUENCES OF ERRORS\">CONSEQUENCES OF ERRORS<\/a><br \/> <a href=\"#APPLICATION USAGE\">APPLICATION USAGE<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#RATIONALE\">RATIONALE<\/a><br \/> <a href=\"#FUTURE DIRECTIONS\">FUTURE DIRECTIONS<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#COPYRIGHT\">COPYRIGHT<\/a> <\/p>\n<hr>\n<h2>PROLOG <a name=\"PROLOG\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This manual page is part of the POSIX Programmer\u2019s Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.<\/p>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">time \u2014 time a simple command<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">time <b>[<\/b>-p<b>]<\/b> <i>utility<\/i> <b>[<\/b><i>argument<\/i>&#8230;<b>]<\/b><\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>time<\/i> utility shall invoke the utility named by the <i>utility<\/i> operand with arguments supplied as the <i>argument<\/i> operands and write a message to standard error that lists timing statistics for the utility. The message shall include the following information:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"2%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"83%\">\n<p>The elapsed (real) time between invocation of <i>utility<\/i> and its termination.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"2%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"83%\">\n<p>The User CPU time, equivalent to the sum of the <i>tms_utime<\/i> and <i>tms_cutime<\/i> fields returned by the <i>times<\/i>() function defined in the System Interfaces volume of POSIX.1-2017 for the process in which <i>utility<\/i> is executed.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"2%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"83%\">\n<p>The System CPU time, equivalent to the sum of the <i>tms_stime<\/i> and <i>tms_cstime<\/i> fields returned by the <i>times<\/i>() function for the process in which <i>utility<\/i> is executed.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">The precision of the timing shall be no less than the granularity defined for the size of the clock tick unit on the system, but the results shall be reported in terms of standard time units (for example, 0.02 seconds, 00:00:00.02, 1m33.75s, 365.21 seconds), not numbers of clock ticks.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">When <i>time<\/i> is used as part of a pipeline, the times reported are unspecified, except when it is the sole command within a grouping command (see <i>Section 2.9.4.1<\/i>, <i>Grouping Commands<\/i>) in that pipeline. For example, the commands on the left are unspecified; those on the right report on utilities <b>a<\/b> and <b>c<\/b>, respectively:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">time a | b | c { time a; } | b | c <br \/> a | b | time c a | b | (time c)<\/p>\n<h2>OPTIONS <a name=\"OPTIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>time<\/i> utility shall conform to the Base Definitions volume of POSIX.1-2017, <i>Section 12.2<\/i>, <i>Utility Syntax Guidelines<\/i>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The following option shall be supported:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"3%\">\n<p style=\"margin-top: 1em\"><b>\u2212p<\/b><\/p>\n<\/td>\n<td width=\"12%\"><\/td>\n<td width=\"74%\">\n<p style=\"margin-top: 1em\">Write the timing output to standard error in the format shown in the STDERR section.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<h2>OPERANDS <a name=\"OPERANDS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The following operands shall be supported:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"12%\">\n<p style=\"margin-top: 1em\"><i>utility<\/i><\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"74%\">\n<p style=\"margin-top: 1em\">The name of a utility that is to be invoked. If the <i>utility<\/i> operand names any of the special built-in utilities in <i>Section 2.14<\/i>, <i>Special Built-In Utilities<\/i>, the results are undefined.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"12%\">\n<p><i>argument<\/i><\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"74%\">\n<p>Any string to be supplied as an argument when invoking the utility named by the <i>utility<\/i> operand.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<h2>STDIN <a name=\"STDIN\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Not used.<\/p>\n<h2>INPUT FILES <a name=\"INPUT FILES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">None.<\/p>\n<h2>ENVIRONMENT VARIABLES <a name=\"ENVIRONMENT VARIABLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The following environment variables shall affect the execution of <i>time<\/i>:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"12%\">\n<p style=\"margin-top: 1em\"><i>LANG<\/i><\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"74%\">\n<p style=\"margin-top: 1em\">Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of POSIX.1-2017, <i>Section 8.2<\/i>, <i>Internationalization Variables<\/i> for the precedence of internationalization variables used to determine the values of locale categories.)<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"12%\">\n<p><i>LC_ALL<\/i><\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"74%\">\n<p>If set to a non-empty string value, override the values of all the other internationalization variables.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"12%\">\n<p><i>LC_CTYPE<\/i><\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"74%\">\n<p>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments).<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%;\"><i>LC_MESSAGES<\/i><\/p>\n<p style=\"margin-left:26%;\">Determine the locale that should be used to affect the format and contents of diagnostic and informative messages written to standard error.<\/p>\n<p style=\"margin-left:11%;\"><i>LC_NUMERIC<\/i><\/p>\n<p style=\"margin-left:26%;\">Determine the locale for numeric formatting.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"11%\">\n<p><i>NLSPATH<\/i><\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"74%\">\n<p>Determine the location of message catalogs for the processing of <i>LC_MESSAGES<\/i>.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"11%\">\n<p><i>PATH<\/i><\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"74%\">\n<p>Determine the search path that shall be used to locate the utility to be invoked; see the Base Definitions volume of POSIX.1-2017, <i>Chapter 8<\/i>, <i>Environment Variables<\/i>.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<h2>ASYNCHRONOUS EVENTS <a name=\"ASYNCHRONOUS EVENTS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Default.<\/p>\n<h2>STDOUT <a name=\"STDOUT\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Not used.<\/p>\n<h2>STDERR <a name=\"STDERR\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">If the <i>utility<\/i> utility is invoked, the standard error shall be used to write the timing statistics and may be used to write a diagnostic message if the utility terminates abnormally; otherwise, the standard error shall be used to write diagnostic messages and may also be used to write the timing statistics.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If <b>\u2212p<\/b> is specified, the following format shall be used for the timing statistics in the POSIX locale:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">&#8220;real %fnuser %fnsys %fn&#8221;, <<i>real seconds<\/i>>, <<i>user seconds<\/i>>, <br \/> <<i>system seconds<\/i>><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">where each floating-point number shall be expressed in seconds. The precision used may be less than the default six digits of <b>%f<\/b>, but shall be sufficiently precise to accommodate the size of the clock tick on the system (for example, if there were 60 clock ticks per second, at least two digits shall follow the radix character). The number of digits following the radix character shall be no less than one, even if this always results in a trailing zero. The implementation may append white space and additional information following the format shown here. The implementation may also prepend a single empty line before the format shown here.<\/p>\n<h2>OUTPUT FILES <a name=\"OUTPUT FILES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">None.<\/p>\n<h2>EXTENDED DESCRIPTION <a name=\"EXTENDED DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">None.<\/p>\n<h2>EXIT STATUS <a name=\"EXIT STATUS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">If the <i>utility<\/i> utility is invoked, the exit status of <i>time<\/i> shall be the exit status of <i>utility<\/i>; otherwise, the <i>time<\/i> utility shall exit with one of the following values:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"7%\">\n<p style=\"margin-top: 1em\">1-125<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"77%\">\n<p style=\"margin-top: 1em\">An error occurred in the <i>time<\/i> utility.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"7%\">\n<p>126<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"77%\">\n<p>The utility specified by <i>utility<\/i> was found but could not be invoked.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"7%\">\n<p>127<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"77%\">\n<p>The utility specified by <i>utility<\/i> could not be found.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<h2>CONSEQUENCES OF ERRORS <a name=\"CONSEQUENCES OF ERRORS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Default.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>The following sections are informative.<\/i><\/p>\n<h2>APPLICATION USAGE <a name=\"APPLICATION USAGE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>command<\/i>, <i>env<\/i>, <i>nice<\/i>, <i>nohup<\/i>, <i>time<\/i>, and <i>xargs<\/i> utilities have been specified to use exit code 127 if an error occurs so that applications can distinguish \u2018\u2018failure to find a utility\u2019\u2019 from \u2018\u2018invoked utility exited with an error indication\u2019\u2019. The value 127 was chosen because it is not commonly used for other meanings; most utilities use small values for \u2018\u2018normal error conditions\u2019\u2019 and the values above 128 can be confused with termination due to receipt of a signal. The value 126 was chosen in a similar manner to indicate that the utility could be found, but not invoked. Some scripts produce meaningful error messages differentiating the 126 and 127 cases. The distinction between exit codes 126 and 127 is based on KornShell practice that uses 127 when all attempts to <i>exec<\/i> the utility fail with <b>[ENOENT]<\/b>, and uses 126 when any attempt to <i>exec<\/i> the utility fails for any other reason.<\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">It is frequently desirable to apply <i>time<\/i> to pipelines or lists of commands. This can be done by placing pipelines and command lists in a single file; this file can then be invoked as a utility, and the <i>time<\/i> applies to everything in the file.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Alternatively, the following command can be used to apply <i>time<\/i> to a complex command:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">time sh -c &#8216;<i>complex-command-line<\/i>&#8216;<\/p>\n<h2>RATIONALE <a name=\"RATIONALE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">When the <i>time<\/i> utility was originally proposed to be included in the ISO\u00a0POSIX-2:1993 standard, questions were raised about its suitability for inclusion on the grounds that it was not useful for conforming applications, specifically:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"2%\">\n<p style=\"margin-top: 1em\">*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"83%\">\n<p style=\"margin-top: 1em\">The underlying CPU definitions from the System Interfaces volume of POSIX.1-2017 are vague, so the numeric output could not be compared accurately between systems or even between invocations.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"2%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"83%\">\n<p>The creation of portable benchmark programs was outside the scope this volume of POSIX.1-2017.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">However, <i>time<\/i> does fit in the scope of user portability. Human judgement can be applied to the analysis of the output, and it could be very useful in hands-on debugging of applications or in providing subjective measures of system performance. Hence it has been included in this volume of POSIX.1-2017.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The default output format has been left unspecified because historical implementations differ greatly in their style of depicting this numeric output. The <b>\u2212p<\/b> option was invented to provide scripts with a common means of obtaining this information.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">In the KornShell, <i>time<\/i> is a shell reserved word that can be used to time an entire pipeline, rather than just a simple command. The POSIX definition has been worded to allow this implementation. Consideration was given to invalidating this approach because of the historical model from the C shell and System V shell. However, since the System V <i>time<\/i> utility historically has not produced accurate results in pipeline timing (because the constituent processes are not all owned by the same parent process, as allowed by POSIX), it did not seem worthwhile to break historical KornShell usage.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The term <i>utility<\/i> is used, rather than <i>command<\/i>, to highlight the fact that shell compound commands, pipelines, special built-ins, and so on, cannot be used directly. However, <i>utility<\/i> includes user application programs and shell scripts, not just the standard utilities.<\/p>\n<h2>FUTURE DIRECTIONS <a name=\"FUTURE DIRECTIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">None.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>Chapter 2<\/i>, <i>Shell Command Language<\/i>, <i>sh<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The Base Definitions volume of POSIX.1-2017, <i>Chapter 8<\/i>, <i>Environment Variables<\/i>, <i>Section 12.2<\/i>, <i>Utility Syntax Guidelines<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The System Interfaces volume of POSIX.1-2017, <i>times<\/i>()<\/p>\n<h2>COPYRIGHT <a name=\"COPYRIGHT\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology &#8212; Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http:\/\/www.opengroup.org\/unix\/online.html .<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https:\/\/www.kernel.org\/doc\/man-pages\/reporting_bugs.html .<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  time \u2014 time a simple command <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3782,1],"tags":[2511,1165],"class_list":["post-5713","post","type-post","status-publish","format-standard","hentry","category-1p-posix-comandos-generales","category-sin-categoria","tag-man1p","tag-time"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/5713","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=5713"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/5713\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=5713"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=5713"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=5713"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}