Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write failed : broken pipe

Tags:

terminal

ssh

I have a headless Ubuntu server. I ran a command on the server (snapraid sync) over SSH from my Mac. The command said it would take about 6 hrs, so I left it over night.

When I came down this morning, the Terminal on the Mac said: "Write failed: broken pipe"

I'm not sure if the command executed fully. Is this a timeout issue? If so, how can I keep the SSH connection alive overnight?

like image 202
Garry Pettet Avatar asked Nov 05 '12 08:11

Garry Pettet


People also ask

What is write broken pipe?

The broken pipe is a TCP/IP error occurring when you write to a stream where the other end (the peer) has closed the underlying connection.

What does NCAT broken pipe mean?

A 'Broken pipe' message happens when you write to a stream where the other end has been closed. In your example, your handle_connection routine reads a single buffer from the client, copies that back to the client, and then returns, which will close the stream.

What does broken pipe mean Linux?

Broken pipe occurs when a process prematurely exits from either end and the other process has not yet closed the pipe. Example use case: A user has just recently reinstalled RVM (Ruby Version Manager) after he performed a fresh install of Ubuntu.


2 Answers

This should resolve the problem for Mac osX version: 10.8.2

add:

ServerAliveInterval 120 TCPKeepAlive no 

to this file:

~/.ssh/config 

Or, if you want it to be a global change in the SSH client, to this file

/private/etc/ssh_config

"ServerAliveInterval 120" basically says to "ping" the server with a NULL packet every 120s, and "TCPKeepAlive no" means to not set the SO_KEEPALIVE socket option (since you shouldn't need it with ServerAliveInterval already set, and apparently it's "spoofable" or some odd).

The servers similarly have something they could set for the same effect (ClientKeepAliveInterval) but typically you don't have control over those settings as much.

like image 114
jeremyforan Avatar answered Sep 21 '22 15:09

jeremyforan


You can use "screen" util for that. Just connect to the server over SSH, start screen session by "screen" command execution, start your command there and disconnect (don't exit screen session). When you think your command already done you can connect to the server and attach to your screen session where you can see the command execution result/progress (in case one should be).

See "man screen" for more details.

like image 29
humkins Avatar answered Sep 21 '22 15:09

humkins