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?

  • 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 8 '11 at 18:59
  • 4
    ...or tmux. See also: unix.stackexchange.com/questions/4034/… – jasonwryan Oct 8 '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 8 '11 at 19:08

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.