I have a script tmp.sh
#!/bin/bash
echo hello
sleep 3
echo 3
I want to log the script running time (as well as script stdout) to a log file.
user$ time ./tmp.sh >& log.tmp
real 0m3.003s
user 0m0.000s
sys 0m0.003s
does not work.
user$ time ./tmp.sh 2>&1 log.tmp
hello
3
real 0m3.003s
user 0m0.002s
sys 0m0.001s
this also does not work.
What is the correct way to log the output of time
command to log file?