4

Given that...

~$ which time
time is a shell keyword
time is /usr/bin/time

Why this works?

~$ /usr/bin/time --verbose ./some_script.sh 
Command being timed: "./some_script.sh"
User time (seconds): 0.00
System time (seconds): 0.01
Percent of CPU this job got: 51%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.03
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 4572
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 1
Minor (reclaiming a frame) page faults: 1548
Voluntary context switches: 3
Involuntary context switches: 7
Swaps: 0
File system inputs: 48
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0

And why this doesn't?

~$ time --verbose ./some_script.sh 
--verbose: no se encontrĂ³ la orden

real    0m0.124s
user    0m0.101s
sys 0m0.022s

2 Answers2

10

When you invoke a command without specifying path to it, others shell alias, function, builtin with the same name will be invoked, instead of command. This behavior was defined by POSIX.

In order to call external time command, you can use command:

command time --verbose cmd
cuonglm
  • 153,898
  • Also note that using "command" this way may not work the same in a non-interactive shell. To work under nohup for example I gave up on command and used this form instead: nohup /usr/bin/time --verbose echo & – Greg Smith Dec 09 '20 at 20:25
4

Because /usr/bin/time and the time built into your shell are completely different implementations. Run help time to get the usage of the one built into your shell, and obviously man time for the one in /usr/bin/time.

user3188445
  • 5,257