Logrotate
From CBLFS
Revision as of 17:11, 12 October 2007 by Weibullguy (talk | contribs)
Download Source: | http://cross-lfs.org/~arowland/tarballs/l/logrotate-3.7.4.tar.gz |
---|
Contents
Introduction to Logrotate
Logrotate is a utility for automatically rotating log files. Logrotate use a configuration file to determine the conditions that must be satisfied to rotate a log file. Logrotate can be run manually, but would typically be run as a cron job.
Project Homepage: Unknown
Dependencies
Required
Recommended
Non-Multilib
Compile the package:
make
Install the package:
make install
Multilib
This package does not install any libraries so only one installation is needed.
32bit
Compile the package:
make CC="gcc ${BUILD32}"
Install the package:
make install
N32
Compile the package:
make CC="gcc ${BUILDN32}"
Install the package:
make install
64bit
Compile the package:
make CC="gcc ${BUILD64}"
Install the package:
make install
Configuring
Create the logrotate configuration file.
cat >> /etc/logrotate.conf << EOF # Begin of /etc/logrotate.conf # Rotate log files weekly. weekly # Send mail to no one. nomail # If the log file is empty, it do not rotate it. notifempty # Number of backups that will be kept. # This will keep the 2 newest backups only. rotate 2 # Create new empty files after rotating the old ones # This will create empty log files, with owner # set to root, group set to root, and permissions 644. create 0664 root root # Compress the backups with gzip. compress # RPM packages drop log rotation info in this directory. # Uncomment if you use RPM packages. # include /etc/logrotate.d # End of /etc/logrotate.conf EOF
Add each of the log files in /var/log to /etc/logrotate.conf to be rotated if they exceed 100K in size:
for logfile in $(find /var/log/*.log -type f); do echo $logfile {>> /etc/logrotate.conf echo # If the log file is larger than 100kb, rotate it >> /etc/logrotate.conf echo size=100k >> /etc/logrotate.conf echo } >> /etc/logrotate.conf echo "">> /etc/logrotate.conf done
Cron Job
Assuming you have Fcron installed, create a cron job:
cat >> /etc/fcrontab << EOF 0 12 * * * 0 /usr/sbin/logrotate /etc/logrotate.conf EOF
Contents
Installed Directories: | None |
---|---|
Installed Programs: | logrotate |
Installed Libraries: | None |
Symlinks: | None |
Short Descriptions
logrotate | is a utility that rotates and optionally compresses old log files. |
---|