A log file can grow without bounds if it is not managed well. Larger
log files are relatively harder to manipulate and also increase in the
size of log file can result in file systems to run out of space.
Opening, closing and manipulating data for very large file size
consumes system resources and will therefore slow down the server.
An efficient solution to this problem is log rotation. It
allows automatic rotation, compression, removal and mailing of log
files. Log files can be rotated daily, weekly, monthly or when it grows
too large.
Normally, log rotate is run as daily cron job, it will not modify a
log file multiple times in a day unless the criteria for that log file
is based on log file’s size or force option is being used. Log files can
be rotated on daily or weekly basis by using the log rotate package in
WHM. Files will only be rotated when they grow larger than the threshold
value of 300MB.
cPanel log rotation configuration feature allows to choose which log
files should be manipulated by cPanel’s cpanellogd daemon. This daemon
will take any specified log files, compress them, and store them to
/usr/local/cpanel/logs/archive/ with a file for each month. The files
stored in that directory by cpanellogd will be left indefinitely, these
has to be removed manually, “rm” command can be used to remove the old
files.
The main configuration file /etc/logrotate.conf, sets up the default
and then reads in a directory of instructions for specific sets of log
files from the /etc/logrotate.d directory. Some of the directives which
can be included in the log rotation configuration file are:
*compress - old versions of log files are compressed
*monthly,weekly,daily – intervals at which files are to be rotated
*compresscmd - specifies which command is to be used to compress log files (by default it is gzip)
*copy - makes a copy of the log file, but doesn’t change the original at all
*delaycompress - postpone compression of the previous log file to the next rotation cycle
*copytruncate - truncate the original log file in place after
creating a copy, instead of moving the old log file and optionally
creating a new one
*mail address - when a log is rotated out-of-existence, it is mailed to a mail address.
The above is a very rough outline of Cpanel log rotation
No comments:
Post a Comment