1

From my home pc using putty, I ssh'ed into a remote server, and I ran a python program that takes hours to complete, and as it runs it prints stuff. Now after a while, my internet disconnected, and I had to close and re-open putty and ssh back in. If I type 'top' I can see the python program running in the background with its PID number. Is there a command I can use to basically re-open that process and see it printing its stuff again?

Thanks

omega
  • 40,311
  • 81
  • 251
  • 474
  • You [screen](http://www.rackaid.com/blog/linux-screen-tutorial-and-how-to/) or [tmux](http://tmux.sourceforge.net/) on your server to have processes running when you disconnect. – Marcin Mar 06 '15 at 02:19
  • 1
    I think you should use screen in the first place. – Stephen Lin Mar 06 '15 at 02:24
  • 1
    Look here, it shows you how to use screen for your problem: http://linuxcommando.blogspot.com/2013/10/how-to-use-screen-command-to-run.html – Dmitry Mar 06 '15 at 02:38

2 Answers2

0

Things to try:

nohup, or

screen

mrflash818
  • 930
  • 13
  • 24
0

As noted, best practice is to use screen or tmux (before starting the program, so you do not need to ask this question).

But you can also attach to a running process with a debugger such as gdb (alluded to here as ddd, a wrapper for gdb), as well as with strace (see this question). That's better than nothing - but gdb and strace would not give you the program's command-line again (though this question suggests a way). At least strace could give you some clues of what the program was attempting to print.

Community
  • 1
  • 1
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105