Is it possible to grab / intercept the output from an already running Java program?
This is my situation: I’m running a program which takes some hours to finish. So I start it and let the computer do it’s work. I can login on the computer running the program with SSH and see the it running with ps, but I would like to intercept the output which is written to the console.
Is there any way to do this?
Do I need to provide extra information?
Start the application in a
screensession, detach from the session and later you can ssh in and reattach to see the progress.Here’s some information on using screen.
Another option is to redirect the standard ouput and standard error to a file, and use something like
tailto view its content. example:my_program &> /tmp/outputOk, I just realized I was a bit offtopic, because I handled the cases where you had to think ahead. Now, if tou want to get it from a running process you can use
gdb.This will put the output to
/tmp/outputand again, you can usetailto see it interactively.