Tail a log-file over the network

tail -f error_log | nc -l 1234
Netcat is used to serve a log-file over a network on port 1234. Point a browser to the specified server/port combo to view log-file updates in real-time.

By: zlemini
2010-05-07 18:14:04

2 Alternatives + Submit Alt

What Others Think

That doesn't seem to work with my Firefox. How does netcat handle the http procol ?
dooblem · 639 weeks and 5 days ago
Sorry i should have mentioned i tested this on MacOS. Here is the Linux (Ubuntu) version: ( echo -e "HTTP/1.0 200 Ok\n\r"; tail -f error_log; ) | nc -lp 1234
zlemini · 639 weeks and 5 days ago
I did as you posted in your comment, but my nc man pages says that l and p cannot be used together, nc won't start; I'm on Ubuntu 10.04, my nc version is: OpenBSD netcat (Debian patchlevel 1.89-3ubuntu2)
Montecristo · 639 weeks ago
I've taken the last version from sourceforge but it still doesn't work, when I point my browser to http://localhost:1234 it keeps loading...
Montecristo · 639 weeks ago
there are two versions of netcat. One should be started with -l -p and another one without -p. Yeah, welcome to the unix world. This command doesn't work well because browser buffers some amount of data and if nothing is written to the transferred file nothing is shown. Additionally this command doesn't work with chrome browser.
ichbins · 494 weeks and 2 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: