Make socat write to (TCP or UNIX) socket line by line for log gathering [closed]
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this questionI'm trying to merge several log files from multiple hosts. I'm doing a socat -u EXEC:'follow_log_cmd' UNIX-SENDTO:/tmp/socket
for each log I want to follow.
On the log gathering machine I'm doing socat -u UNIX-RECV:/tmp/socket -
My problem is that log entries are getting overlapp开发者_开发问答ed sometimes because socat's not writing one line at a time, but instead a buffer at a time.
Is there any way to make it write one line at a time?
Try using a pseudo terminal to make socat's writing line buffered:
- socat -u EXEC:'follow_log_cmd' UNIX-SENDTO:/tmp/socket
+ socat -u EXEC:'follow_log_cmd',pty,ctty UNIX-SENDTO:/tmp/socket
See also: https://stackoverflow.com/questions/1000674/turn-off-buffering-in-pipe
精彩评论