Find how long a command takes to complete
Some times it is required to know how long a command is taking to execute, especially in case of huge scripts. The command “time” can be used to determine the time taken by a command or a script. The following example shows how it can be used.
[liz@techpulp ~]# time sleep 3 real 0m3.016s user 0m0.000s sys 0m0.008s [liz@techpulp ~]#
In the above example we attempted to determine time taken by the command “sleep 3” using time command. After the command finishes, time prints the information on standard error. This information contains “real” which is actual time taken by the command from the invocation to finish. In the information, “user” tells you how much time this process has spent in user space and “sys” tells you how much time system (kernel) spent time on behalf of this process. Note that for this particular command “sleep 3“, the process is put on sleep so there is no significant amount of time spent in user space or kernel space. That is the reason why “user” and “sys” times are lower compared to real time taken by the command to finish.

