Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use `tail -f logfile' to view the log in real time. I also need to know how many lines are appended to the logfile per second. Is there a command to do this?

share|improve this question

You can use 'wc -l logfile' to see linecount. Do it in loop to watch it in real time. This one works at least in bash:

while true; do wc -l logfile; sleep 1; done
share|improve this answer
While this will work, it is very resource intensive, particularly on a logfile which you expect to grow very quickly. It is also inaccurate as it greps the logfile and then waits 1 second. The time spent grepping the logfile is thus additional to the sleep time, and very significant. – davidgo Mar 28 '13 at 20:42
My log file was very large. wc -l would take a few seconds to finish. So I prefer not to read the entire file each time. – woodings Mar 28 '13 at 20:48

I don't believe there is a simple, built in way to see how many lines are appended a second, but depending on the problem you are trying to solve there may be some options -

  1. If you just want a very rough indication, you could work out the average length of a line, and then monitor the size of the file, and do some basic maths for a rough indication.

  2. Depending on what creates the log file, you should be able to redirect the log output to a script which counts the lines received before passing it through to a file it writes. I can't advise on writing this script unless I know more about the use case, particularly how the log file is created, and what syslog program you are using.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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