Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automate the archiving and deletion of log files

Status
Not open for further replies.
Aug 30, 2004
12
0
0
CA
Hi:

Does anyone know of a available script that can help me out in managing accumulated logs?

specs:
- tars and gzips log files, after the files are a certain date
- deletes files after a specified time
 
man find

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
The logrotate utility is great for this, it's usually found on Linux but you can find or compile it for other OSs.

Annihilannic.
 
We have this to gzip all Oracle redo logs except the most recent. These are then deleted after a specified number of days within the backup script:
Code:
#!/usr/bin/ksh
cd /path/to/logs
ls -rt | grep -v gz | grep -v loglist> loglist
lines=`wc -l loglist | tr -s ' ' ' ' | cut -f2 -d ' '`
if [ $lines -gt 1 ]
then
head -`expr $lines - 1` loglist > loglist1
for file in `cat loglist1`
do
gzip $file 2> /dev/null
done
fi

Oh, and apologies for the UUOC there, this was written in more innocent times!

Alan Bennett said:
I don't mind people who aren't what they seem. I just wish they'd make their mind up.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top