Index Click this button to go to the index for this section.


time(1)

NAME

time - Times the execution of a command

SYNOPSIS

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.

STANDARDS

Interfaces documented on this reference page conform to industry standards as follows: time: XPG4, XPG4-UNIX Refer to the standards(5) reference page for more information about industry standards and associated tags.

OPTIONS

-p Writes the timing output to standard error. This is the default.

OPERANDS

command 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. argument 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.

DESCRIPTION

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.

NOTES

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)

EXIT STATUS

The time command returns the following exit values if the command could not be invoked: 1-125 An error occurred in the time command. 126 The command specified by command was found but could not be invoked. 127 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.

EXAMPLES

1. 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 2. 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

The following environment variables affect the execution of time: LANG 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. LC_ALL If set to a non-empty string value, overrides the values of all the other internationalization variables. LC_CTYPE 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). LC_MESSAGES Determines the locale for the format and contents of diagnostic messages written to standard error. NLSPATH Determines the location of message catalogues for the processing of LC_MESSAGES. PATH Determines the path used to locate command.

SEE ALSO

Commands: csh(1), ksh(1), Bourne shell sh(1b), POSIX shell sh(1p) Functions: times(3) Standards: standards(5)