1

I ssh in to my ubuntu machine usimg mobaxterm.

This works very well.

Sometimes I want to keep a process running but exit my ssh session (and exit mobaxterm). I have tried the following but regardless as soon as I close mobaxterm my process on the target machine dies, using firefox as an example:

ssh => 
tmux;
firefox & disown;
tmux detach;
exit;

ssh => 
screen firefox & disown;
exit;

I'm sure I've made a really stupid mistake but looking around other posts on this topic I thought I had followed their recomendations but to no evail.

thanks in advance.

Clarification: I can detach my process succesfully using screen or nohup, but is it possible to shut the ssh client and keep the detached process running?

1

Two options to avoid automatic killing a detached process:

  1. Using screen: screen is an Unix utility which allows you to keep a live session, after your logged-out.

    • To start screen, enter the following command:

    screen

    • Detach but keep shell window open

    press Ctrl a d

    • Resume your screen session:

    screen -r

You should use screen in the following way:

  1. ssh into the server
  2. start screen
  3. execute the commands you want to run
  4. detach screen (ctrl-a-d)
  5. exit the server andclose ssh connection

The processes should keep running in the server

You'll be able to see it, when you'll:

  1. ssh into the server
  2. resume screen screen -r
  3. check relevant logs, ps -ef , etc

More info:

More info: - man nohup

  • As per my op, I've tried screen, I've also tried nohup, but when I exit my ssh client (mobaxterm) the process I started is killed. So I suppose what I am asking is, is it possible to shut the ssh client and keep the detached process running? – lazarus Mar 6 '17 at 10:25
  • @danm - screen should work, I've updated my answer with step-by-step instructions how to use screen – Yaron Mar 6 '17 at 10:30
0

Clarification: I can detach my process succesfully using screen or nohup, but is it possible to shut the ssh client and keep the detached process running?

Yes.

This is remarkably easy to test for yourself too.

  • ok, well thats not my experience, so something else must be going on – lazarus Mar 6 '17 at 10:34
  • I use ssh + screen all the time. It just works. – Iain Mar 6 '17 at 10:35
  • what ssh client do you use? – lazarus Mar 6 '17 at 10:52
  • putty/kitty and openssh. – Iain Mar 6 '17 at 10:57
  • I have just tried putty, I can detach the process fine (as with mobaxterm) but if I shut the actual putty app my detached process is also killed. – lazarus Mar 6 '17 at 11:12

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.