time
performance monitoringLinux/Unix
The time command is one of the most frequently used commands in Linux/Unix-like operating systems. time Measure program execution time
Quick Reference
Command Name:
time
Category:
performance monitoring
Platform:
Linux/Unix
Basic Usage:
time [options] [arguments]
Common Use Cases
Syntax
time [options] command [arguments...]
Options
Option | Description |
---|---|
Note: The options below are for GNU time (/usr/bin/time). The shell built-in time command usually has limited or no options. | |
-f FORMAT, --format=FORMAT |
Specify output format, with placeholders for various statistics |
-p, --portability |
Use the portable output format |
-o FILE, --output=FILE |
Write the resource use statistics to FILE instead of stderr |
-a, --append |
Append to the output file instead of overwriting it |
-v, --verbose |
Give very verbose output about all the program knows about |
--help |
Print a usage message and exit |
--version |
Print version information and exit |
Format Specifiers for -f option (GNU time) | |
%E |
Elapsed real time (in [hours:]minutes:seconds) |
%e |
Elapsed real time (in seconds) |
%U |
Total number of CPU-seconds that the process spent in user mode |
%S |
Total number of CPU-seconds that the process spent in kernel mode |
%P |
Percentage of the CPU that this job got (user + system times / elapsed time) |
%M |
Maximum resident set size of the process during its lifetime (in Kbytes) |
%t |
Average resident set size of the process (in Kbytes) |
%K |
Average total (data+stack+text) memory use of the process (in Kbytes) |
%D |
Average size of the process's unshared data area (in Kbytes) |
%p |
Average size of the process's unshared stack (in Kbytes) |
%X |
Average size of the process's shared text (in Kbytes) |
%Z |
System's page size (in bytes) |
%F |
Number of major page faults that occurred |
%R |
Number of minor page faults that occurred |
%W |
Number of times the process was swapped out of main memory |
%c |
Number of times the process was context-switched involuntarily |
%w |
Number of waits: times that the program was context-switched voluntarily |
%I |
Number of file system inputs by the process |
%O |
Number of file system outputs by the process |
%r |
Number of socket messages received by the process |
%s |
Number of socket messages sent by the process |
%k |
Number of signals delivered to the process |
%C |
Name and command-line arguments of the command being timed |
%x |
Exit status of the command |
Examples
How to Use These Examples
The examples below show common ways to use the time
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
# Time a simple command
time ls -la