The Computer Oracle

What happens to running processes when I lose a remote connection to a *nix box?

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Ominous Technology Looping

--

Chapters
00:00 What Happens To Running Processes When I Lose A Remote Connection To A *Nix Box?
00:49 Answer 1 Score 0
01:18 Accepted Answer Score 8
01:57 Thank you

--

Full question
https://superuser.com/questions/143925/w...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#linux #unix #bash #ssh #remoteaccess

#avk47



ACCEPTED ANSWER

Score 8


Normally the processes will terminate upon disconnection, but the old SSH sessions could either be waiting to timeout, or they could have hung upon exit, due to a race condition.

You should probably terminate the old sessions, although you don't necessarily have to. Type ps aux on the console to list the processes, then kill PID for each hung ssh session, where PID is the PID (process ID) for that session. The older, hung sessions should have lower PIDs than your current, new session.

If there is a long-running process that you specifically want to continue running even after you disconnect, you can prefix your command with nohup:

nohup badblocks -nvs /dev/sda &



ANSWER 2

Score 0


When the ssh session dies, the pseudo-tty associated is closed and reset. Typically the shell and other processes associated with that tty are killed, as they are child processes of the process that created it. If there are processes hanging around, perhaps they had been backgounded? Yes, they should probably be killed - cleanliness is next to godliness. They do take up some resources - not usually much, but it can add up after awhile.