[Linux-disciples] Deleting the first N lines of a file

Adam Rosi-Kessel adam at rosi-kessel.org
Thu Feb 9 09:19:36 EST 2006


Stephen R Laniel wrote:
> On Wed, Feb 08, 2006 at 09:47:39PM -0500, Adam Rosi-Kessel wrote:
>> Why does it need to be so fast? Maybe you're asking the wrong question.
> The large file we're working with is an Apache logfile.
> Doing the 'head' command and then overwriting the logfile
> will lose us some hits. We'd prefer not to lose any hits at
> all, which is why we'd like to just pull the top N lines off
> the file, write them to another file, and then delete the
> top N lines off the original file.

Hmm. And you don't want to just do the standard rotation thing?

What if the Apache logfile were actually a fifo? Then you could have a
script that continuously read lines from the fifo and outputted them to
another file, and whenever it felt like rotating, it could start outputting
them to a new file.  I've never seen that done, but it seems like it would
solve your problem of 100% preservation of hits.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 250 bytes
Desc: OpenPGP digital signature
Url : http://lists.bostoncoop.net/pipermail/linux-disciples/attachments/20060209/9081ddd7/signature.pgp


More information about the Linux-disciples mailing list