Tutorial :alternative to tail -F


I am monitoring a log file by doing "TAIL -n -0 -F filename". But this is taking up a lof of CPU as there are many messages being written to the logfile. Is there a way, I can open a file and read new/few entries and close it and repeat it every 5 second interval? So that I don't need to keep following the file? How can I remember the last read line to start from the next one in the next run? I am trying to do this in nawk by spawning tail shell cmd.


You won't be able to magically use less resources to tail a file by writing your own implementation. If tail -f is using resources because the file is growing fast, a custom version won't help any if you still want to view all lines as they are being written. You are simply limited by your hardware I/O and/or CPU.


Try using --sleep-interval=S where "S" is a number of seconds (the default is 1.0 - you can specify decimals).

tail -n 0 --sleep-interval=.5 -F filename  

If you have so many log entries that tail is bogging down the CPU, how are you able to monitor them?

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »