tail will sometimes output more lines than it is told if the file is being appended to. I believe this is occurs when data is written to the file after tail computes where to start displaying data, but before the display starts. Fix: No known fix. tail could declare the end of the file (when -f is not done) to be the length of the file when it first touches it, but that could cause additional problems. How-To-Repeat: Run one program that continuously prints out lines to a file: while [ 1 ]; do echo test; done > file While that is running, run a bunch of tails and compute their length for i in `seq 1 1000`; do tail file | wc -l | done > linecnt (In case it's not clear from the name, seq prints out 1 through 1000) Look at the distribution of the line counts that were displayed: sort -n linecnt | uniq -c On my run: 975 10 1 61 1 68 1 118 1 131 1 134 2 138 1 168 2 170 1 174 1 205 1 227 1 235 1 259 1 291 1 348 1 362 1 367 1 797 1 1170 1 1562 1 2198 1 5738 1 5861
in How-To-Repeat it should be while [ 1 ]; do echo test; done > file and for i in `jot 1000 1`; do tail file | wc -l; done > linecnt ( - freebsd uses jot, seq is gnu and if you install it via the port /usr/ports/misc/sh-utils you have to invoke it with 'gseq' - semikolon before done ) I have got an easy workaround for it: if a file is written to (or could be) while you want to 'tail' it, just do an cat file | tail that gives tail a snapshot of the file and the results of the above test are correct. but someone should document this in man1/tail.1
I wrote this little note for the tail.1 manpage. I am still new to this and I'm not sure, if this should be mentioned in the manpage or not. If the text is ok, please someone proofread and maybe commit it. Otherwise, some commentary would be nice. thanks
Responsible Changed From-To: freebsd-bugs->edwin Grab.
For bugs matching the following criteria: Status: In Progress Changed: (is less than) 2014-06-01 Reset to default assignee and clear in-progress tags. Mail being skipped