why not use tee? because the terminal rendering of the output makes the application run slower.
for some reason, this is not working:
application 2>&1 >"$logFile"
the output keeps going to terminal..
You have redirected stderr
to stdout
(the terminal), then you've redirected stdout
to a file. In conclusion, you haven't redirected stderr
to the file:
stderr -> stdout
, stderr
goes to the terminal.stdout -> $logfile
, stdout
goes to the $logfile
.Try using the following:
application >"$logfile" 2>&1
Notice the order matters:
stdout -> $logfile
, stdout
goes to $logfile
.stderr -> stdout -> $logfile
, stderr
goes to stdout
which is the same as $logfile
.application 2>&1 |cat >"$logfile"
, and also this script -c "/path/prog" /path/log.txt
Jul 17, 2013 at 4:18
/dev/tty
directly, but there's no way to know without knowing which program it is.echo ping | tee > /dev/null
and it did not show anything.