UNIX/Linux Time Command : Record elapsed time


In a recent post I mentioned using a scratchpad to record everything I do. As part of that process I try to make regular use of the UNIX/Linux “time” command to record elapsed times of long running commands.

It’s really simple to use. All you do is put “time” in front of the command and it will display how long it takes to complete the command. In this example I do a sleep for 10 seconds and use the time command to report the elapsed time. 🙂

$ time sleep 10

real    0m10.002s
user    0m0.001s
sys     0m0.001s

Clearly that’s a silly example, but it gives you an idea of how this works.

If you get into the habit of using this with all long running processes, you can get accurate timings for steps. That way, when someone asks you how long something takes you can give them a real answer, rather than making something up and hoping for the best.

Just remember, timings can vary if the load on the system varies between runs. Even so it’s always nicer to have some real data to inform your decisions going forward. Especially when planning for something that will cause disruption in production. 🙂



Author: Tim...

DBA, Developer, Author, Trainer.

2 thoughts on “UNIX/Linux Time Command : Record elapsed time”

  1. Also, with time you will have a record of how installation (or whatever the script is intended to do) times have improved with newer Oracle versions.

  2. The other handy way of timing, if you have a lot of commands in bash script and you want a total at the end.


    #do stuff you want to time
    eval “echo Elapsed Time $(date -ud “@$duration” +’$((%s/3600/24)) days %H hours %M minutes %S seconds’)”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.