Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Removing old records from log files

by idnopheq (Chaplain)
on Aug 22, 2001 at 14:19 UTC ( #106906=note: print w/ replies, xml ) Need Help??


in reply to Removing old records from log files

Is there a specific reason you want to edit/truncate it in place? Seems like it maybe a lot of work and risky at that. It may be easier to simply rotate the log throughout the day, compressing the older ones to save space. Have you checked out rotating files, is there a better way?? Are these files flat text, or something else? A search on google may be a good idea. I seem to run across log rotation scripts every few weeks.

NON-perl: I recall in *nix copying the whole file into a new one (filename.0), then something like echo /dev/null > filename. Finally, I'd gzip or bzip2 the logfile.0. YMMV.

HTH
--
idnopheq
Apply yourself to new problems without preparation, develop confidence in your ability to to meet situations as they arrise.


Comment on Re: Removing old records from log files
Re: Re: Removing old records from log files
by claree0 (Hermit) on Aug 22, 2001 at 14:28 UTC

    This log file is in fact an extract of a much larger log file. I do the extraction so that the bare minimum (!) is kept in this file so that it is available to other processes, and archive the originals. It is not possible to rotate this 'extract' log file, but as it updates every 6 hours I do not run into problems with file locking while I trim it, as I ensure that the two do not overlap.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://106906]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2014-07-10 10:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (206 votes), past polls