The linux time result is not written to the file

I am using debian. run my program using the time command and get the time result written to the file as follows:

time. / myprog> out.asc

The ./ output of myprog is written to out.asc, but not the result of time. is there any way to send time output also out.asc? thanks!

+4
source share
3 answers

time always writes to stderr. To save this with bash, use 2>&1 to write to the same place as stdout (you need brackets, so you get a time stderr, not just stderr myprog):

 (time ./myprog) > out.asc 2>&1 

You can also get time information in a separate file:

 (time ./myprog) > out.asc 2> timing_info 
+11
source

Try (time. / Myprog)> out.asc 2> & 1

+1
source

Source: https://habr.com/ru/post/1314576/


All Articles