|
Posted by Tyrone Slothrop on 10/10/92 11:39
On Fri, 10 Feb 2006 14:35:13 +0100, "Pete" <@> wrote:
>I'm having some log files from different php scripts on my website. I would
>like to make script that reduces the log files to 500 lines, etc., when I
>think they are growing too big. What is the best way to do this? The only
>way I know is to import the file into an array and write back the latest 500
>lines, but is there a better way?
>
Comments:
It is more efficient to rename and create a file than truncate a file
based on the number of lines. I usually do a daily rotation of log
files, keeping a five day backup should I need to refer to them. You
could also evaluate file size as a condition. The scripts that write
to the logs should create the file should it not exist.
[Back to original message]
|