6

The question I know is basic, but could not find an exact matching question in community.
The standard process of using tmux is - create a session, run command within and then detach the session. So existing ssh terminal will not kill our process.

My question is, if tmux session is created and a long command is running within it. But before detaching, if ssh session terminates, then will this tmux session persist or it will be killed too?

0

1 Answer 1

4

Basically after losing an ssh connection the child process will receive a SIGHUP. This signal causes tmux to detach itself from the lossen ssh session.

So tmux's session will stay persistent on a remote machine even if ssh session gets terminated.


Test it yourself:

  1. Open a terminal and run tmux.
  2. In your "tmux" session run sleep 100.
  3. Open another terminal and run: pkill -1 tmux.
    • Now tmux has been closed in the first terminal.
  4. Run tmux ls to see that your sessions is still there.
    • Or tmux attach to bring it up.

I have also tested the actual losing ssh session scenario on a remote machine, result is the same.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .