4

So, I ssh into my remote computer and launch a process... time passes... my ssh session breaks. I log in again, and of course, I don't have access to the original process now. I can see it still if I ps -ax but I can't do nothing about it other than kill it. Which, sometimes, may not be advisable, such as when the original process is, say, vacuuming a sqlite3 database.

So, can I get control of that process from a previous broken ssh session? If yes, how?

punkish
  • 141
  • 4
    Try running all your ssh processes inside a GNU screen session, which you can detach and re-attach at will. screen to start a session, C-a d to detach it, screen -d -r to detach and reattach. – jw013 Oct 08 '11 at 18:59
  • 4
    ...or tmux. See also: http://unix.stackexchange.com/questions/4034/how-can-i-disown-it-a-running-process-and-associate-it-to-a-new-screen-shell – jasonwryan Oct 08 '11 at 19:06
  • awesome... thanks. Will have to learn the ins and outs of screen, but seems like it will be worth it. – punkish Oct 08 '11 at 19:08

1 Answers1

3

Take a look at /proc/PID/fd/ there you can see what happend to your old stdin and stdout. Sometimes you can use echo to send something to the stdin device of that process.

If you just want to prevent commands from being killed after your session breaks you can start them with nohup.

But the best answers to your question are possibly the comments about screen resp. tmux.

Nils
  • 18,492