Track the time a command takes in UNIX/LINUX?
LinuxUnixCommand LineTerminalLinux Problem Overview
In UNIX/LINUX, is there an easy way to track the time a command takes?
Linux Solutions
Solution 1 - Linux
Solution 2 - Linux
Use
/usr/bin/time
instead that the time builtin in the bash: it is more configurable AFAIK.
e.g. /usr/bin/time --format=' \n---- \nelapsed time is %e'ls
Solution 3 - Linux
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
Solution 4 - Linux
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