OneChillDude
OneChillDude

Reputation: 8006

Track the time a command takes in UNIX/LINUX?

In UNIX/LINUX, is there an easy way to track the time a command takes?

Upvotes: 119

Views: 67535

Answers (5)

Paolinux
Paolinux

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

RogerW
RogerW

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.

StasShip in Action

Upvotes: 0

Jarchiii
Jarchiii

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

Guillaume Chevalier
Guillaume Chevalier

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

squiguy
squiguy

Reputation: 33360

Yes, use time <command>, such as

time ls

Consult man time for more options. Link.

Upvotes: 165

Related Questions