1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

Discuss in my forum

Introduction to Linux

By Machtelt Garrels

4.3.2. How long does it take?

Bash offers a built-in time command that displays how long a command takes to execute. The timing is highly accurate and can be used on any command. In the example below, it takes about a minute and a half to make this book:


   

 
billy:~/xml/src> time make
 Output written on abook.pdf (222 pages, 1619861 bytes).
 Transcript written on abook.log.
 
 real	1m41.056s
 user	1m31.190s
 sys	0m1.880s
 

The GNU time command in /usr/bin (as opposed to the shell built-in version) displays more information that can be formatted in different ways. It also shows the exit status of the command, and the total elapsed time. The same command as the above using the independent time gives this output:


   

 
billy:~/xml/src> /usr/bin/time make
 Output written on abook.pdf (222 pages, 1595027 bytes).
 Transcript written on abook.log.
 
 Command exited with non-zero status 2
 88.87user 1.74system 1:36.21elapsed 94%CPU 
 				(0avgtext+0avgdata 0maxresident)k
 0inputs+0outputs (2192major+30002minor)pagefaults 0swaps
 

Refer again to the Info pages for all the information.

* License

* Introduction to Linux Index

  1. About.com
  2. Technology
  3. Linux

©2014 About.com. All rights reserved.