1828390 Members
2960 Online
109977 Solutions
New Discussion

cleaning log files

 
Thomas CREDOZ
New Member

cleaning log files

Hello,

I would like to clean up log files during they are open (e.g. the access log of a web server). On HP-UX i can do that by using "cat /dev/null > LOGFILE". After that the LOGFILE is empty. If I do the same on Linux, the content of the file is overwritten with NULL characters and the file size remains the same as before. New entrys to the file are appended after the NULL characters.
Is there a way to clean up log files like on HP-UX?
I know that there is a solution for the apache web server but I need a solution for other software as well.

Thank you
3 REPLIES 3
Albert E. Whale, CISSP
Honored Contributor

Re: cleaning log files

Andreas,

The problem which you are pointing to is that which happens when you truncate a file (in this case a logfile) which has open connections to it.

If you weere to temporaily suspend the application or tell it to restart immediately after truncating the logfile, then size will be reduced. As long as the file remains open, the original length of the file will be preserved, according to the open file handles.

Hope this helps.
Sr. Systems Consultant @ ABS Computer Technology, Inc. http://www.abs-comptech.com/aewhale.html & http://www.ancegroup.com
Chris Fishwick
New Member

Re: cleaning log files

Andreas,

A solution to your problem is to issue the command "> LOGFILE_NAME", this will zero the log file, and start it fresh.

e.g. "> /var/log/messages"

Hope that this helps you.

Regards

Chris
How much truth can money buy?

Re: cleaning log files

Did you already try:

> LOGFILE



With Regards,

Dieter Degrendele
Dieter@Work