3

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..

3
  • May be, tee has some options to suppress output?
    – Danatela
    Jul 17, 2013 at 3:14
  • Which application? It might be doing something screwy like writing to /dev/tty directly, but there's no way to know without knowing which program it is.
    – Paul
    Jul 17, 2013 at 3:14
  • And it is not clear what do you try to achieve. I just made the command echo ping | tee > /dev/null and it did not show anything.
    – Danatela
    Jul 17, 2013 at 3:19

1 Answer 1

6

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:

  1. stderr -> stdout, stderr goes to the terminal.
  2. stdout -> $logfile, stdout goes to the $logfile.

Try using the following:

application >"$logfile" 2>&1

Notice the order matters:

  1. stdout -> $logfile, stdout goes to $logfile.
  2. stderr -> stdout -> $logfile, stderr goes to stdout which is the same as $logfile.
1
  • omg, worked thx! I found this to work too application 2>&1 |cat >"$logfile", and also this script -c "/path/prog" /path/log.txt Jul 17, 2013 at 4:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .