Today I struggled with the time command.

I wanted to use it in a bash script, so I checked the man page, where I found interesting stuff :

$ man time
time - run programs and summarize system resource usage

time   [ -apqvV ] [ -f FORMAT ] [ -o FILE ]
[ --append ] [ --verbose ] [ --quiet ] [ --portability ]
[ --format=FORMAT ] [ --output=FILE ] [ --version ]
[ --help ] COMMAND [ ARGS ]

-o FILE, --output=FILE
-f FORMAT, --format FORMAT

Ok great. So I wrote my command like this :

$ time -f %E  wget -q --timeout=60 --connect-timeout=60 -O - 'http://my-url' >>/dev/null
-su: -f: command not found

hm. Maybe I did something wrong. Let’s try the man page’s example to understand how things work :

$ time -f "%E real,%U user,%S sys" ls -Fs
-su: -f: command not found

wtf??! The example given didn’t work either !
And then

$ time --help
-su: --help: command not found

ok… so, searching a little bit further helped me find the explanation :

Your shell (apparently bash) provides a builtin time function. If you want to use time binary, call it by absolute path (/usr/bin/time)

let’s try :

$ /usr/bin/time -f %E  wget -q --timeout=60 --connect-timeout=60 -O - 'http://my-url' >>/dev/null

Finally! It was just a silly thing…

Just remember, when using the bash time, get the time in minutes/seconds:

$ time wget -q --timeout=60 --connect-timeout=60 -O - 'http://my-url' >>/dev/null

and in seconds only :

$ time wget -q --timeout=60 --connect-timeout=60 -O - 'http://my-url' >>/dev/null


Comments are closed.
non ultricies consequat. Donec pulvinar lectus libero efficitur. eget Nullam sit