繁體中文 |
简体中文 |
English
arclog.pl v1.4.1
WHAT'S NEW?
arclog.pl v1.4.1 released. You could click here to download.
DESCRIPTION
arclog.pl archives the log files monthly. It strips off
the log entries that belongs to the previous months, and save them to
the archived files named logfile.yyyymm. The archive
files will be compressed. The entries of the current month will be
kept in the source. It then saves disk spaces and prevents potentially
attacks on log files.
Current, only the apache access log and
syslog formats are recognized.
CAUTION
-
Archiving takes time, especially on large log files. If
logging continues when you archive the file, it might be destroyed by
simultaneously writing. arclog.pl uses flock
to obtain an exclusive locking on the file to avoid such a racing
condition. But not all programs, especially the logging mechanisms
like httpd or syslogd, use
flock. (And, if they do, arclog.pl would
never have a chance to work as long as they aren't turned off.) Make
sure you are not logging to that file when running
arclog.pl. You should always turn off logging before
running arclog.pl, or run arclog.pl on a
file that's not logging currently.
-
You could optionally sort the records in the archived files by time
(and then by record order), to solve some problems on merged log
files. But BE CAUTIONED: Sorting eats huge memory and CPU. If
you work on large log files, it might kill the whole system in one
minute. I had made some simple steps to avoid that, but I CAN'T
GUARANTEE THAT IT WORKS. Whether it kills depends on which CPU
you have, how much memory you have and how large your archived file
is. Because of this, by default sorting is turned off.
-
Be careful on the syslog log files: syslog
does not record the year. arclog.pl uses
Date::Parse to parse the date, which will smartly
judge the year in the range between this month and last next month.
For ex., if today is 2001-06-08, it will judge the year between
2001-06-30 back to 2000-07-01 if the year is missing. I think this is
smart enough. However, if you do have a syslog log file
that has records older than that, don't use arclog.pl. It
will destroy your log file.
SYSTEM REQUIREMENT
-
Perl, version 5.005 or above. This program uses the File::Temp module,
which requires some new features introduced from perl 5.005.
Perl is distributed with most Unix now. If not, or if you have an
older version of perl, you could download and install/upgrade it from
http://www.perl.com/.
If you are using MS-Win32, you can download and install from
http://www.activestate.com/.
-
Required perl modules:
File::Spec::Functions,
File::Temp,
Date::Parse,
Compress::Zlib.
You can always search, download and install the missing perl modules
from the the CPAN archieve:
http://search.cpan.org/.
DOWNLOAD
You could always download the newest version of arclog.pl from the
following addresses:
INSTALL
-
Extract the downloaded tar ball
% tar -xzf arclog.pl-x.xx.xx.tar.gz
-
Install using the installation script (recommended)
Although this program does not need configurations, it is still
recommended that you run the installation script. It will check
anything this program needs and warn you in advance if something is
missing.
You'll have to install File::Spec::Functions first in order to run
the installation script. It is included in the perl distributions
from v5.6.0. If you are using an older version of perl without it,
you could download and install it from the CPAN archive:
http://search.cpan.org/.
Goto the extracted directory, run the Install.PL
% ./Install.PL
It will check everything it needs and prompt you necessary settings.
Answer them according to your needs. Then it will install the program
according to your answers. You could also try
% ./Install.PL --help
for a list of available command line options.
-
Manual set up and install
Copy the arclog.pl to your favorite directory. Make sure it is
executable.
% chmod +x arclog.pl
That's all.
-
Run
Run it and see if anything wrong. You could try
% ./arclog.pl --help
for a list of available command line options. Try
% perldoc arclog.pl
for a complete document of this program.
OPTIONS
./arclog.pl [options] [--prefix=prefix] logfile
./arclog.pl [-h|-v]
- logfile
-
The log file to be archived.
- -p, --prefix=pre
-
The prefix of the output files. The output files will be named as
pre.yyyymm, ie: pre.200001,
pre.200002. If not specified, the default is the full
pathname of the log file.
- --compress
-
Compress the archived files. This is the default. Log files often have
simular lines all over. Compress them saves you lots of disk spaces.
(And this is why we want to archive the log files.) Currently
only the gzip compressing method is supported.
- --nocompress
-
Don't compress the archived files. (Are you sure? :p )
- --sort
-
Sort the records by time (and then the record order). Sorting eats
huge memory and CPU, so the default is disabled. See the description
above for a detailed illustration on sorting.
- --nosort
-
Don't sort the records. This is the default.
- --override[=mode]
-
Whether we should overwrite the existing archived files. Currently
the following modes are supported:
- overwrite
-
Overwrite any existing target file. If --override was
specified without mode, it assumes that you want to
overwrite. You will lost these existing log records. Use with care.
This is only helpful if you are sure the master log file has the most
complete records.
- append
-
Append the records to the existing target files. You might destroy the
log file completely by putting irrelevant entries altogether
accidently. Use with care. This is only helpful if you append want to
merge 2 log files, for ex., 2 log files in the same kind with
exclusive date ranges.
- ignore
-
Ignore any existing target file, and discard all the records of those
months. You will lost these log records. Use with care. This is only
helpful if you are supplying log records for the missing months, or if
you are merging the log records in a complex manner.
- fail
-
Stop processing whenever a target file exists, to prevent destroying
any existing files by accident. This is the default behavior, since
this is mostly wanted when run from some automatic mechanism like
crontab.
- ask
-
Ask you what to do when a target file exists. This should be most
wanted if you are running this interactively. Don't set to ask if you
are running from non-interactively shells, like crontab. I don't know
what will happen then. Maybe it will wait indefinitely.
- -d, --debug
-
Show the detailed debugging messages.
- -q, --quiet
-
Shihhhhhh. Only yell when errors.
- -h, --help
-
Display the help message and exit.
- -v, --version
-
Output version information and exit.
COPYRIGHT
Copyright © 2001 imacat. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
RELEASE NOTES
Please read the RELEASE_NOTES for the new functions and bug fixes.
by imacat <imacat@mail.imacat.idv.tw>, first version 2001-06-08, last updated 2001-06-08

This page conforms with HTML 4.01 / CSS2 recommendations