2

I'm developing with vi over ssh.

My problem is that sometimes I get my ssh connection killed because of my poor wifi connection and previous processes (like "top", "rails c", etc...) are not being killed properly.

So after a little while, i get those processes at 100% of the CPU usage (i don't really know why), and I need to kill them manually.

Because I'm not the only developer, it can get really messy so my boss asked me to come up with a solution.

How would i do this?

3 Answers 3

4

There are several ways around this:

  1. Kill the leftover processes.
  2. Use something to compensate for the disconnections.

The second option is the easiest with screen or tmux.

After your connection has dropped you reconnect, log back in and resume your screen/tmux session, then continue working where you left. (For screen use screen -r to resume).

If you ever used remote desktop in windows, then you can compare this with resuming a disconnected RDP session.

4
  • I also use screen in such situations as well. Good answer. +1. Jul 31, 2012 at 14:57
  • Can you tell me how to kill the leftover processes? Aug 1, 2012 at 13:42
  • First get the process ID of the leftover process. Use can use a command such as ps for this. Then use 'kill -1 processID. This will send the process a SIGHUP. Loosely translated this will tell the process "User has disconnected. Please end yourself in a proper way'. Most programs which receive this signal will save files, close databases etc. If that fails use kill -15 or kill -9 (-15 is terminate to the process. Like -1 but more insistent. -15 is not sent to the process but to the OS. It is a 'kill with prejeduce' command which might leave a mess.
    – Hennes
    Aug 1, 2012 at 13:48
  • You probably can't do this automatically. The dropped [WiFi] connection should already have caused the shell on the other and to signal all processes with SIGHUP before terminating itself.
    – Hennes
    Aug 1, 2012 at 14:55
1

If you are using ssh with an unreliable connection, you may want to give mosh a try: http://mosh.mit.edu/

Mosh was exactly written for this purpose. Note that you need it installed on both sides.

-1

ssh -t Seems to work as I wanted.

1
  • 1
    Care to elaborate?
    – aefxx
    Aug 14, 2014 at 8:46

You must log in to answer this question.

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