I want to pipe the output of time command rather than the output of the job it is measuring the time of. I tried
/usr/bin/time -v java RandomTest > time.log
But that redirects java RandomTest's output to time.log
I want to pipe the output of time command rather than the output of the job it is measuring the time of. I tried
/usr/bin/time -v java RandomTest > time.log
But that redirects java RandomTest's output to time.log
This one is a bit tricky, but you can do it as follows:
{ time java RandomTest ; } 2> time.log
This way the result of time goes into time.log, and stdout from java RandomTest stays in your tty.
Try it first with:
{ time ls ; } 2> tmp.txt
cat tmp.txt
At least on recent Linux distributions, the time command supports the -o FILE option:
/usr/bin/time -v -o time.log java RandomTest
You could redirect also the stderr e.g. with >& in bash or zsh
(the >& is the same as 2>&1 since its redirects stderr to stdout)