LinuxBasics.org

The community that helps people to run Linux

rss
Table of Contents

Time will tell

Sometimes it is interesting to see how long a program took to run. This is usefull to see how long a backup took to be complete, how long you surfed the net, or many other things.

This is taken from one of my posts to a mailing-list I used to subscribe:

Date

stw@laptop:~> date ; echo This line intentionally left blank ; sleep 5 ; date
Sa Jun 18 20:47:59 CEST 2005
This line intentionally left blank
Sa Jun 18 20:48:04 CEST 2005

which will tell you start and end of the run of the program (tar, netscape, whatever). You have to do the math on your own.

Time

‘time’ does this:

stw@laptop:~> time sleep 5
 
real    0m5.066s
user    0m0.002s
sys     0m0.002s

So we know how long the nap really was, and how much time the CPU spent to run the sleep-application. The drawback is that ‘time’ only times one command. So if you want to time pipes or multiple commands that run after each other, you need to put them into a script and time that script, or use ‘date’ and do the math… :(


Copyright (c) by the authors.
Prior to editing, authors agreed to license their contributions by the terms of the GPL.
See our licensing page for details.


Linux® is a registered trademark of Linus Torvalds.


 
  tutorials/advanced/realworld/time_will_tell.txt · Last modified: 2008/07/20 19:08

LinuxBasics.org

Start Linux-Course Tutorials Linux Links Security Blog Forum E-mail List Search Online Chat

Site-Info

Help Get in Touch Making of LBo

Wiki-Control

Powered by

Linux Apache DokuWiki Mailman RUTE ht://Dig