No local-side tool can do this, because of what the server "sees":
- if you disconnect SSH gracefully, the server will notice this immediately;
- if you just disappear (e.g. by a hard reset), the connection will stay open on the server side until some kind of timeout (compare
ClientAlive* options, TCP keepalive concept – see this answer for some details).
Even if you intended to use tmux-resurrect or another tool on the local side, the server doesn't know, doesn't care. It will terminate your long-running code unless you used nohup or better…
If you can, use tmux (or screen) on the server:
- Don't enter
tmux session on the client.
ssh to the server.
- Start
tmux session on the server.
- Launch long-running code there.
- Disconnect anyhow: gracefully or not, with or without detaching from the remote
tmux.
ssh again.
- Your
tmux session is still there (unless something bad happened to the server in the meantime); reattach with tmux a.
I use tmux this way on daily basis and I think this is the right way. On my laptop tmux sessions last for few hours at most, I shut it down every night; but I have access to a couple of servers where my tmux sessions run for months. When I'm writing this, on one of them there's watch df -h process running literally for a week in a tmux session started like two months ago.