Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

2 Answers 2

(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

and

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

 
discard

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.