Classnotes | UNIX03 | RecentChanges | Preferences If your log files continue to grow and grow unchecked, you may eventually run out of drive space. Even worse (and more likely) the log files will grow to a point where they are no longer managable for the administrator. So how do we combat this?
One answer (and the most common one at that) is to use Logrotate. Logrotate is designed to ease administration of systems that generate large numbers of log files. It allows automatic rotation, compression, removal, and mailing of log files. Each log file may be handled daily, weekly, monthly, or when it grows too large
Normally, Logrotate runs as a cron job (usually in cron.daily), however it is completely possible to run it manually. It checks its configuration, prepares a variety of scripts, and then proceeds to split and rotate the log files it is set up to manage.
Taking a look in /var/log, you may find files such as these:
Taking a look just at maillog (which is a log of the mail transactions taking place with this Postfix-based system), we see that the current maillog with all of today's transactions is:
maillog
Then, we have rotated maillogs separated by several days:
maillog.1
maillog.2
maillog.3
maillog.4
If you will note, the dates on these files do vary quite a bit. This is because Logrotate can be configured to rotate logs based upon size, date, or a number of other settings.
Logrotate is used by default on many Linux distributions such as Red Hat, Debian, Gentoo, and Mandrake. However, you should be aware that not all distributions presently include it by default (two examples are SUSE and SCO).