time - Times the execution of a command
time [-p] command [argument...]
The time command prints the elapsed time during the execution
of a command, the time spent in the system, and the
time spent in execution of the command on the diagnostic
output system.
Note
The C shell has a built-in version of the time command.
If you are using the C shell, and want to guarantee that
you are using the command described here, you must specify
the full path /usr/bin/time. See the csh(1) reference
page for a description of the built-in command.
Interfaces documented on this reference page conform to
industry standards as follows:
time: XCU5.0
Refer to the standards(5) reference page for more information
about industry standards and associated tags.
Writes the timing output to standard error. This is the
default.
The name of a command to be executed. If command identifies
any name specified as a special built in your applicable
shell reference page, the results are undefined and
unpredictable. The argument to be passed to command. See
the appropriate reference pages for these values. This
parameter may include flags and arguments expected by command.
The time command prints the elapsed time during the execution
of a command, the time spent in the system, and the
time spent in execution of the command on the diagnostic
output system. Time is reported in seconds.
The time command (with a different format) is also built
into csh.
When time is used as part of a pipeline, the times
reported are unspecified, except when it is the sole command
within a grouping command in that pipeline. For example,
the commands on the left are unspecified; those on
the right report on utilities a and c, respectively.
time a | b | c { time a } | b | c a | b | time c
a | b | (time c)
The time command returns the following exit values if the
command could not be invoked: An error occurred in the
time command. The command specified by command was found
but could not be invoked. The command specified by command
could not be found.
If the command was successfully invoked, the exit status
of time is the exit status of command.
To measure the time required to run a program, enter: time
a.out
This runs the program a.out and writes to the standard
error output the amount of real, system, and
user time that it uses: real 10.5 user 0.3 sys
3.6 To measure the time required by a complex command,
enter: time sh -c 'complex-cmmand-line'
This runs all of the commands, which may include
pipelines, and returns the time information for the
entire series of commands.
ENVIRONMENT VARIABLES [Toc] [Back] The following environment variables affect the execution
of time: Provides a default value for the internationalization
variables that are unset or null. If LANG is unset
or null, the corresponding value from the default locale
is used. If any of the internationalization variables
contain an invalid setting, the utility behaves as if none
of the variables had been defined. If set to a non-empty
string value, overrides the values of all the other internationalization
variables. Determines the locale for the
interpretation of sequences of bytes of text data as characters
(for example, single-byte as opposed to multibyte
characters in arguments). Determines the locale for the
format and contents of diagnostic messages written to
standard error. Determines the location of message catalogues
for the processing of LC_MESSAGES. Determines the
path used to locate command.
Commands: csh(1), ksh(1), Bourne shell sh(1b), POSIX
shell sh(1p)
Functions: times(3)
Standards: standards(5)
time(1)
[ Back ] |