Skip to content
TrySitePrice

Linux / Unix: time Command Examples

Best/Tutorial

The time command in Linux and Unix measures the time it takes to run a command or a script. Here are some examples of how to use the time command:

  1. Measure the time it takes to run a command:

    time

  2. Measure the time it takes to run a shell script:

    time sh

  3. Measure the real, user, and system time consumed by a command:

    time -v

  4. Measure the time it takes to run a command and save the output to a file:

    time   >

rnWhere is the command you want to measure the time for and is the file where you want to save the output.

The time command is a useful tool for measuring the performance of commands and scripts, and for optimizing code. The output of the time command can be used to identify performance bottlenecks and to make informed decisions about performance optimization.