3

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?

lazarus
  • 131

2 Answers2

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

Yaron
  • 221
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.

user9517
  • 117,122