times
Report process and child process time
TLDR
Print CPU usage. First line is current shell CPU usage for User and System. Second is all child processes
SYNOPSIS
times
DESCRIPTION
The times command is a shell built-in that displays the cumulative user and system CPU times consumed by the shell itself and by any child processes that have terminated. User time is the amount of time the CPU spends executing code in user mode, while system time is the amount of time the CPU spends executing code in kernel mode on behalf of the process. This command provides a quick overview of the CPU resources utilized by the current shell session and its completed background jobs or commands. It's particularly useful for understanding the resource consumption of scripts or interactive sessions.
Unlike the external time utility, times aggregates the statistics for all child processes that have exited since the shell started or since the last times command was executed. It's a fundamental tool for basic performance monitoring within a shell environment.
CAVEATS
times is a shell built-in command, meaning its behavior and exact output format can vary slightly between different shells (e.g., Bash, Zsh, Ksh).
It reports cumulative CPU times for completed child processes, not for currently running processes.
It measures CPU time, not wall-clock (real) time.
The times reported for children are for all children that have terminated since the shell started or the last call to times, not just the most recently completed one.
OUTPUT FORMAT EXPLAINED
The output typically consists of two lines:
The first line displays the cumulative user and system time for the shell itself.
The second line, if any children have terminated, shows the cumulative user and system time for all children of the shell that have completed execution since the shell started or the last times command was run.
For example:
0m0.00s 0m0.00s
0m0.00s 0m0.00s
The format 'minutesmseconds.milliseconds' is common, but some shells might just output total seconds or a different precision. The exact format depends on the shell implementation.
HISTORY
The times command is a standard part of the POSIX shell specification, making it available across various Unix-like operating systems and shells compliant with POSIX. Its purpose has remained consistent: to provide an aggregate view of CPU time consumption for the shell and its children. It has been a stable and fundamental feature of shell environments for a long time, evolving as part of the broader shell specifications.