Difference between revisions of "Logrotate"

From CBLFS
Jump to navigationJump to search
(Added page.)
 
Line 16: Line 16:
 
* [[Fcron]]
 
* [[Fcron]]
  
== Non-Multilib ==
+
== Non-Multilib or Multilib ==
 
 
Compile the package:
 
 
 
make
 
 
 
Install the package:
 
 
 
make install
 
 
 
== Multilib ==
 
 
 
<b><i>This package does not provide any libraries so only one installation is required.</i></b>
 
 
 
=== 32Bit ===
 
 
 
Compile the package:
 
 
 
make
 
 
 
Install the package:
 
 
 
make install
 
 
 
=== N32 ===
 
 
 
Compile the package:
 
 
 
make
 
 
 
Install the package:
 
 
 
make install
 
 
 
=== 64Bit ===
 
  
 
Compile the package:
 
Compile the package:

Revision as of 10:35, 1 April 2007

Download Source: http://webpages.charter.net/weibullguy/tarballs/logrotate-3.7.4.tar.gz

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.

Package Homepage: ?

Dependencies

Recommended

Non-Multilib or Multilib

Compile the package:

make

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.
Retrieved from "?title=Logrotate&oldid=8536"