[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Commands Reference, Volume 5

time Command

Purpose

Prints the time of the execution of a command.

Syntax

time [ -p ] CommandArgument ... ]

Description

The time command prints the elapsed time during the execution of a command, time in the system, and execution time of the time command in seconds to standard error.

Note: Sleep time is not charged to either system or user time.

The time command is also built into the C shell (csh) and Korn shell (ksh) with a different format. To run the time command while in the csh and ksh shells, enter:

/usr/bin/time

Flags

-p Writes the timing output to standard error. Seconds are expressed as a floating-point number with at least one digit following the radix character.

The standard format for this flag is as follows:

"real %f\nuser %f\nsys %f\n", <real seconds>, <user seconds>, <system seconds>

Exit Status

If you use the Command parameter, the exit status of the time command is the exit status of the specified command. Otherwise, the time command exits with one of the following values:

1-125 Indicates an error occurred in the time command.
126 Indicates the command specified by the Command parameter was found but could not be invoked.
127 Indicates the command specified by the Command parameter could not be found.

Examples

  1. To measure the time required to run a program, enter:

    /usr/bin/time -p a.out

    This command runs the program a.out and writes the amount of real, user, and system time to standard error, in the format specified by the -p flag; for example:

    real      10.5
    user      0.3
    sys       3.6
  2. To save a record of the time command information in a file, enter:

    /usr/bin/time a.out 2> a.time

Files

/usr/bin/time Specifies the path of the time command.

Related Information

The timex command.

System Accounting in AIX 5L Version 5.2 System Management Guide: Operating System and Devices.

Accounting Commands in AIX 5L Version 5.2 System Management Concepts: Operating System and Devices.

Accounting Overview in AIX 5L Version 5.2 System Management Concepts: Operating System and Devices.

Using the time Command to Measure CPU Use in AIX 5L Version 5.2 Performance Management Guide.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]