Professional Documents
Culture Documents
From : http://www.stardothosting.com
These log files could be anything: java logs, apache logs (apache should have its
own log rotation built in) and mail logs for example. This script has two modes :
daily and monthly.
The daily mode is intended to be run daily (obviously) , gzipping the previous
days log file. The monthly mode, run monthly (obviously), then tar’s up all the
previous month’s gzip files into one big tarball.
Note that this script assumes the log filenames are assorted by the filename +
date (year/month/day). This can obviously be modified to suit the specific syntax
of your log file names.
#!/bin/sh
# Rotate / compress old logs
# Star Dot Hosting
The above entries run the script daily at 3:00am, and monthly on the 1st of every
month at 5:00am, this ensures the script isn’t run at the same time on the 1st as
the daily job.
That’s it!