Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I started a process on my Linux machine through Putty by running a jar. Now the program will take at least 24 hours to run, and my Putty terminal session has been interrupted. I have added code in the program to output information to track the progress of the job via System.out.println. If I know the PID of the process, is there any way to open a new terminal session in Putty and view the output the process is currently outputting, as if I were in the same session from which I executed the JAR?

Thanks,

share|improve this question
    
For future reference, I would just redirect the output to a text file for something like this. –  squiguy Aug 26 '12 at 0:56
    
strace -p PID would be a crude way to find out what it's currently printing. For future reference... run screen when you log in via ssh, then if you get disconnected you can log in and run screen -r to pick up where you left off. –  Alan Curry Aug 26 '12 at 1:05
add comment

migrated from stackoverflow.com Aug 27 '12 at 1:00

This question came from our site for professional and enthusiast programmers.

1 Answer

You can attach your process to a new terminal like this:

git clone https://github.com/nelhage/reptyr.git
cd reptyr/
make

And grep for you JAR PID:

ps -ef | grep "YOUR_JAR"

Then :

./reptyr YOUR_JAR_PID

And you'll see that the current session will be attached to your JAR.

More on this great tool : http://blog.nelhage.com/2011/01/reptyr-attach-a-running-process-to-a-new-terminal/

share|improve this answer
add comment

Your Answer

 
discard

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