Reputation: 8006
In UNIX/LINUX, is there an easy way to track the time a command takes?
Upvotes: 119
Views: 67535
Reputation: 177
Use
/usr/bin/time
instead of the time
builtin in bash
: it is more configurable AFAIK.
e.g. /usr/bin/time --format=' \n---- \nelapsed time is %e'ls
Upvotes: 7
Reputation: 516
Install https://github.com/starship/starship . Its very customizable., but out the box it willshow the duration of how long the command took. I don't find that Starship impacts performance too much on the terminal prompt, so its a good choice.
Upvotes: 0
Reputation: 426
The command time
is built-in in the bash but it can also be installed on most distros by installing the package "time" (apt install time) and must be accessed by doing /usr/bin/time
.
Using /usr/bin/time
offers more convenient options like specifying a format:
time --format="Duration: %e seconds" sleep 3
Upvotes: 0
Reputation: 10888
Here is how a sleep
of one second looks like, timed with time
:
$ time sleep 1
real 0m1.001s
user 0m0.000s
sys 0m0.000s
Upvotes: 6