Reputation: 83
I want to redirect a program's stdout and stderr to a file and print it to screen at the same time, the obvious solution is to use tee:
./my_program 2>&1 | tee log_file
However, because tee isn't activate until the program finishes execution, I can't see the program output in real-time.
Is there a way to have the same effect while being able to see what a program prints in real-time ?
Upvotes: 0
Views: 877
Reputation: 75565
Yes, redirect to a file directly and use tail -f
to follow the output.
./my_program 2>&1 > log_file
tail -f log_file
Upvotes: 2