Linux command
time 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Measure execution time of a command
time [command]
Measure time with verbose output
/usr/bin/time -v [command]
Output to a file
/usr/bin/time -o [time.log] [command]
Custom output format
/usr/bin/time -f "Real: %e User: %U Sys: %S" [command]
Append to output file
/usr/bin/time -a -o [time.log] [command]
说明
time measures the execution time of a command, reporting real (wall clock), user (CPU time in user mode), and system (CPU time in kernel mode) times. There are two versions: the shell builtin (bash, zsh) and GNU time (/usr/bin/time). The builtin is simpler; GNU time provides more detailed resource statistics and formatting options. Real time is the actual elapsed time. User time is CPU time executing user code. System time is CPU time in kernel calls. User + System may exceed Real on multi-core systems with parallel execution, or be less if the process waits for I/O.
FAQ
What is the time command used for?
time measures the execution time of a command, reporting real (wall clock), user (CPU time in user mode), and system (CPU time in kernel mode) times. There are two versions: the shell builtin (bash, zsh) and GNU time (/usr/bin/time). The builtin is simpler; GNU time provides more detailed resource statistics and formatting options. Real time is the actual elapsed time. User time is CPU time executing user code. System time is CPU time in kernel calls. User + System may exceed Real on multi-core systems with parallel execution, or be less if the process waits for I/O.
How do I run a basic time example?
Run `time [command]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
Where can I find more time examples?
This page includes 5 examples for time, plus related commands for nearby Linux tasks.