[HPADM] [SUMMARY] - Trimming huge log files from the top

From: Epstein, Kevin (kepstein@uti.co.za)
Date: Mon Mar 17 2003 - 02:50:00 EST


Hi All,

Thanks for the numerous replies.
Most of the replies entail stopping the daemons, and trimming the files like
so:

stop daemon
tail -1000 > logfile.new
rm logfile
mv logfile.new logfile
restart daemon

The above is very safe, in that the daemon will not write anything to the
log while you're trimming your log, though is reliant on some scheduled
downtime. (even if this scheduled downtime is momentary)

Another suggestion:

tail -1000 logfile;cat;cat > logfile

The double cat avoids garbling up the data. This can work while your daemon
is running, but it's a little risky because you will lose out some of the
very latest logs written to the file, if the daemon is writing to the log at
the exact moment, as you are busy trimming the log.

There were some other suggestions about renaming the logs etc, while the
daemons are running, but cannot work, because even when you rename a file,
the daemon still writes to the renamed file because it's writing to an inode
rather than file name, and when the filename changes, the inode is still
consistant.

By All accounts, it seems that I'm probably going to have to do this the
safe way and shut down the daemons, and trim the logs that way.

Thanks again for all the replies!

Rgds,
Kevin Epstein
UTi - Centurion

--
             ---> Please post QUESTIONS and SUMMARIES only!! <---
        To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl
       Name: hpux-admin@dutchworks.nl     Owner: owner-hpux-admin@dutchworks.nl
 
 Archives:  ftp.dutchworks.nl:/pub/digests/hpux-admin       (FTP, browse only)
            http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse & search)


This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 11:02:27 EDT