Make a socket to write to (TCP or UNIX) socket by line for logging

I am trying to merge multiple log files from multiple hosts. I do socat -u EXEC:'follow_log_cmd' UNIX-SENDTO:/tmp/socketfor every magazine I want to use.

On a log collecting machine I do socat -u UNIX-RECV:/tmp/socket -

My problem is that journal entries sometimes overlap because socat does not write one line at a time, but instead a buffer at a time.

Is there a way to get him to write one line at a time?

+3
source share
1 answer

Try using a pseudo-terminal to create a cellular recording buffer:

- 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

+3
source

All Articles