0

Linux time command will produce the output in minute and second format. Is it possible to change it to hour format?

[user@Linux ~]$ time ./script.sh

real    394m30.145s
user    388m20.129s
sys     16m16.255s
[user@Linux ~]$ 

It would be nice if the output can be formatted like this

[user@Linux ~]$ time ./script.sh

real    6 Hours 34 Minutes 30.145s
user    6 Hours 28 Minutes 20.129s
sys     16m16.255s
[user@Linux ~]$ 
1

You can use /usr/bin/time instead as I doubt if the shell time keyword has formatting options.

/usr/bin/time -f "%E" ./script.sh
  • 1
    The time keyword does have formatting options, albeit very limited. See TIMEFORMAT in Bash Variables. – muru Nov 6 '17 at 3:55
  • @muru, thanks but it didn't work user@Linux:~$ /usr/bin/time "%E%" ./script.sh /usr/bin/time: cannot run %E%: No such file or directory Command exited with non-zero status 127 0.00user 0.00system 0:00.00elapsed ?%CPU (0avgtext+0avgdata 1184maxresident)k 0inputs+0outputs (0major+27minor)pagefaults 0swaps user@Linux:~$ – Charlotte Russell Nov 6 '17 at 4:04
  • 1
    @CharlotteRussell that's αғsнιη's answer, and it has -f "%E". Note the -f. – muru Nov 6 '17 at 4:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.