bash builtin: times GNU version
Time a command
and
give resource usage

time [options] command [arguments…]

Runs command arguments , then writes a message to standard error including:

  1. elapsed wall time
  2. user CPU time     (tms_utime + tms_cutime )
  3. system CPU time (tms_stime + tms_cstime )
5.6 wall  0.127 user  0.571 sys  12.45%

-p When in the POSIX locale, use format: real %f\nuser %f\nsys %f\n
(in seconds) with the number of decimals in the output sufficient to express the clock tick accuracy plus 1.

real 0.88
user 0.12
sys 0.32

Environment variables

LANG, LC_ALL, LC_CTYPE, LC_MESSAGES and LC_NUMERIC are used for formatting the output and
NLSPATH and PATH to search for command.

Exit status

is that of command. if command was invoked.
127 command could not be found,
126 command found but could not be invoked,
1-125 something else went wrong. (ambigious with exit status of command.

SEE ALSO

bash builtin: times

GNU version

Output to STDOUT time used, memory, I/O and IPC calls (where available).
The output is formatted using a format string that can be specified using -f or the TIME environment variable.

The default format string is

%Uuser %Ssystem %Eelapsed %PCPU (%Xtext+%Ddata %Mmax)k
%Iinputs+%Ooutputs (%Fmajor+%%Rminor)pagefaults %Wswaps
   Command exited with non-zero status 1
   0.45user 0.04system 0:00.50elapsed 98%CPU (0avgtext+0avgdata 0maxresident)k
   0inputs+0outputs (0major+180minor)pagefaults 0swaps

In the format, ordinary characters are copied, for tab, newline and backslash use \t, \n and \\, for a percent sign use %%, and % indicates a conversion.
Output includes a trailing newline
options in italics are not available is tsch

       Time 
       %E     Elapsed real time (in [hours:]minutes:seconds).  
       %e     Elapsed real time (in seconds).  
       %S     Total number of CPU-seconds spent in kernel mode.  
       %U     Total number of CPU-seconds spent in user mode.  
       %P     Percentage of the CPU, computed as (%U + %S) / %E.

       Memory 
       %M     Maximum resident set size in Kbytes.  
       %t     Average resident set size in Kbytes.  
       %K     Average total (data+stack+text) memory use in Kbytes.  
       %D     Average size of the unshared data area, in Kbytes.  
       %p     Average size of the unshared stack space, in Kbytes.  
       %X     Average size of the shared text space, in Kbytes.  
       %F     page faults where the page was read in from disk.  
       %R     page faults that are not valid but which have not yet been claimed by other virtual pages.
                      the data in the page is still valid but the system tables must be updated.  
       %W     swapped out of main memory.  
       %c     context-switched involuntarily (because the time slice expired).  
       %w     waits: times that the program was context-switched voluntarily, 
                        for instance while waiting for an I/O operation to complete.  
       I/O 
       %I     file system inputs 
       %O     file system outputs 
       %r     socket messages received 
       %s     socket messages sent 
       %k     signals delivered to the process.  
       %C     command  and arguments 
       %x     Exit status of the command.
       %Z     System's page size, in bytes.  per-system constant
-f FORMAT
--format=FORMAT
Specify output format, possibly overriding the format specified in the environment variable TIME.
-p
--portability
output format
          real %e
          user %U
          sys %S
-o file
--output=file
overwrite file
-ao file
--append --output=file
append output to file
-v
--verbose
User time (seconds): 0.46
System time (seconds): 0.04
Percent of CPU this job got: 98%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.51
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 0
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Minor (reclaiming a frame) page faults: 183
Voluntary context switches: 1
Involuntary context switches: 50
Swaps: 0
File system inputs: 0
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 1 
User time (seconds): 5.97
System time (seconds): 0.03
Percent of CPU this job got: 99%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:06.02
Maximum resident set size (kbytes): 6208
Voluntary context switches: 1
Involuntary context switches: 2137


       
--help
Usage: /usr/bin/time [-apvV] [-f format] [-o file] [--append] [--verbose]
       [--portability] [--format=format] [--output=file] [--version]
       [--help] command [arg...]
-V
--version
 
-- end of options
BUGS
Not all resources are measured by all versions of Unix, so some of the values might be reported as zero. The present selection was mostly inspired by the data provided by 4.2 or 4.3BSD. The environment variable TIME was poorly chosen.
It is not unusual for systems like autoconf or make to use environment variables with the name of a utility to override the utility to be used. Uses like MORE or TIME for options to programs (instead of program pathnames) tend to lead to difficulties.

It seems unfortunate that -o overwrites instead of appends. (That is, the -a option should be the default.)

Mail suggestions and bug reports for GNU time to bug-utils@prep.ai.mit.edu
Please include the version of time, which you can get by running time --version and the operating system and C compiler you used.

SEE ALSO tcsh, wait3

bash builtin:

times

Output to stdout the user and system times used by the shell and its children since being invoked.

ex:
0m0.060s 0m0.260s
0m1.250s 0m2.240s

The return status is 0.