I have a server with a bunch of processes writing log files as they run. I need to enable a client host to get a replica of the server-side log files in a near real-time manner. Is there a better way than simply combining tail with netcat?

I was thinking of using tail with netcat on the server side to stream multiple log files through a single connection:

tail -F *.log | nc -lk -p 31377

While the client side would demultiplex the logs and write them to files:

nc serverhost 31377 | demultiplexer

Where demultiplexer is simply built around sed, figuring destination filenames from separators inserted by tail on the server side:

sed -e 's/==> \(.*\) <==/\1/'
  • 1
    shouldn't you use a syslog(3) call, and use system syslogd (or rsyslog.conf) configuration to broadcast ? – Archemar Nov 29 '15 at 14:03
  • Cannot change the way log is written by processes on the server, so trying to find a non-intrusive way. Or do you suggest to first tail the log and then to write it with syslog in a separate process? – Dmitry Aleks Nov 29 '15 at 14:19


 tail -f /path/to/logfile.log | xargs -l logger -p local8.info
  • xargs -l will read line by line.
  • you have to configure syslog.conf to broadcast though. (replacing local8 and info by proper value)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.