Is is possible to print the execution time of a shell command with following combination?
root@hostname:~# "command to execute" && echo "execution time"
Is is possible to print the execution time of a shell command with following combination?
root@hostname:~# "command to execute" && echo "execution time"
If I'm starting a long-running process like a copy or hash and I want to know later how long it took, I just do this:
Which will result in the following output:
Granted, as implemented here it isn't very precise and doesn't calculate the elapsed time. But it's dirt simple and sometimes all you need.
Don't forget that there is a difference between bash's builtin
time
(which should be called by default when you dotime command
) and/usr/bin/time
(which should require you to call it by its full path).The builtin
time
always prints to stderr, but/usr/bin/time
will allow you to send time's output to a specific file, so you do not interfere with the executed command's stderr stream. Also,/usr/bin/time
's format is configurable on the command line or by the environment variableTIME
, whereas bash's builtintime
format is only configured by theTIMEFORMAT
environment variable.For a line-by-line delta measurement, try gnonom.
Just
ps -o etime= -p "<your_process_pid>"
time
is a built-in command in most shells that writes execution time information to the tty.You could also try something like
Or in
bash
:It also distinguishes between real time used and system time used.