LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   strace -f -p pid_no > trace.txt 2>&1 (https://www.linuxquestions.org/questions/linux-newbie-8/strace-f-p-pid_no-trace-txt-2-and-1-a-801025/)

threezerous 04-09-2010 08:19 AM

strace -f -p pid_no > trace.txt 2>&1
 
I was given the above command to trace one of the java processes which was failing with an outofmemory exception.

Based on man I under stand what -f and -p stand for. I also understand redirect output to trace.txt. But I am not clear on what '2>&1' is for. This has successfully run and helped me debug some issues. Can somebody explain what is the significance of '2>&1' is?

Thanks

rayfordj 04-09-2010 08:28 AM

2 is stderr, 1 is stdout

you are effectively saying send/redirect stderr (2) to the same location as stdout (1)

All About Redirection


you might also be interested in the use of strace's output to a file option...

Code:

strace -f -p pid_no -o trace.txt

:study:

threezerous 04-09-2010 09:47 AM

Thanks for helping understand redirection. Also the second command is easier to remember :)


All times are GMT -5. The time now is 12:50 AM.