Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been trying redirect output to logfiles but should NOT be displayed on terminal, but following command does output both on terminal and in logs. Any ideas are appreciated.

(some_cmd | tee -a log1 log2) 2>&1

share|improve this question
is some_cmd a standard utility? – Tim Jun 25 '12 at 12:41
(some_cmd | tee -a log1 log2) 2>&1

That will pass stderr to stdout after tee, therefore it drops to your stdout in terminal.

Try to

some_cmd 2>&1 | tee -a log1 log2 >/dev/null

if you need to store stderr


some_cmd | tee -a log1 log2 >/dev/null 2>&1

in case you don't need stderr output.

share|improve this answer

some_cmd | tee -a log1 | tee -a log2 | ... | tee -a logn > /dev/null

share|improve this answer
Does it log errors to the log files? – doubledecker Jun 25 '12 at 12:16
If you do not want error log to be displayed on terminal, you can replace command as: some_cmd 2> log_file – SHW Jun 25 '12 at 12:18
no luck :-( it is still displaying output on the console – doubledecker Jun 25 '12 at 12:23
look like incomplete answer from me :( – SHW Jun 25 '12 at 12:27
@SHW Not necessarily, we do not know what "some_cmd" is, and some programs dump weird output – Tim Jun 25 '12 at 12:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.