i found that if my internet connection is disconnected during a ssh session to a remote Linux server, and then reconnect within a short time, the ssh session is still alive.

If I am running a program on the server and redirect its stdout and stderr outputs to a file, temporary internet disconnection doesn't seem to stop the program from running.

But will the disconnection affect the content of the file? I thought it wouldn't. I found some content of the file not repeatable when reruning the program without interruption to my internet connection, but I am not sure if the interruption to internet connection is the cause.

  • 3
    One thing if you find your connect gets disrupted with some regularity you might want to use screen or tmux to protect your session. Then even if your connection goes away you can just relogin and connect again Commented Jan 13, 2016 at 18:54
  • The server runs Kerberos, so I don't know how to make screen and tmux work.
    – Tim
    Commented Jan 13, 2016 at 18:59
  • I've never tried it but uisapp2.iu.edu/confluence-prd/display/SOICKB/… suggests running module load screen-kinit within screen so it will get its own ticket, though it will need to be renewed every so often if you want to leave it running for a long time Commented Jan 13, 2016 at 19:06
  • 1
    Possible duplicate of Keep SSH Sessions running after disconnection
    – Jakuje
    Commented Jan 13, 2016 at 19:17
  • This is not a duplicate of that question. It is not asking how to keep a program running. Commented Jan 13, 2016 at 19:52

3 Answers 3


If the session stays active then it stays active. There's no trickery there, just a buffer and TCP doing it's thing.

So if an connection to an ssh session is lost then recovered due to a "poor" internet connection, the app that is running in that session never knows. The session continues.

It's a lot like unplugging your monitor (while looking at the console) should not effect the app running on that console.

  • Thanks. I don't know why the content of the redirection file isnt the same.
    – Tim
    Commented Jan 13, 2016 at 18:59

But will the disconnection affect the content of the file? I thought it wouldn't.

If the connection is interrupted, your session ends and your shell and command is killed. It you are interested in running commands on your remote server even if you disconnect, you should have a look for nohup command, screen or tmux multiplexor or mosh for poor connection shells.


If you want to be certain your program remains running while disconnected, use screen. Then you can deliberately disconnect your ssh connection, come back hours or even days later and reconnect to it (so long as the machine hasn't rebooted, or anything else done to terminate the program, of course)

You must log in to answer this question.

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