Re: Rotating Log-Container

From: Date: Wed, 02 Feb 2005 20:46:05 +0000
Subject: Re: Rotating Log-Container
References: 1 2 3 4  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-35884@lists.php.net to get a copy of this message
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Ian Eure wrote: | On Wednesday 02 February 2005 12:06 pm, Stephan Wentz wrote: | |>Ian Eure wrote: |>| On Wednesday 02 February 2005 10:10 am, Stephan Wentz wrote: |>|>Hmm ok, the part counting the numer of lines doesn't really make sense. |>|>Has anyone got a good idea how to do this without memory being exhausted? |>|> |>|>:) |>| |>| http://packages.debian.org/logrotate |>| |>| I really don't think this belongs in PEAR. |> |>Please read my first post again and rethink what you wrote ;-) |> | | To answer your question, I think the best thing you can do is run `wc - -l' on | the file. | | I think this is still a bad idea, but it's your funeral. Hehe, you've got a rather bad attitude toward this ;-) "wc -l" was my first thought, but even this isn't accessible on my managed host :-( And on Windows-Servers this won't be possible, too. Now I have several options, first: leave out maxLines. Second: use fopen/fgets to get the number of lines. Third: Get an approximate number by dividing the filesize with an average number (of characters in a line). I tried nr 3, it's of course fast, but unreliable. I then checked nr 2 and was positive surprise, it only took 0.001 secs for a logfile >10mb. Setting the size-limit to 1mb should reduce this amount farther. So I guess I'll stick with this method until someone has an idea for a better solution, without using system-calls. Stephan -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCATwN8qQ9XV7tBNQRAm1ZAJ9VcEYT/DrlmMvbWN41xQ8rMKmyVACdHGaw s+QCZL43ikiJS5czinHXIrU= =gDdh -----END PGP SIGNATURE-----

« previous php.pear.dev (#35884) next »