Difference between revisions of "Logrotate"

From CBLFS
Jump to navigationJump to search
(Added page.)
 
 
(9 intermediate revisions by 3 users not shown)
Line 2: Line 2:
 
|-
 
|-
 
!Download Source:
 
!Download Source:
|http://webpages.charter.net/weibullguy/tarballs/logrotate-{{Logrotate-Version}}.tar.gz
+
|http://cross-lfs.org/~cosmo/wiki_files/logrotate-{{Logrotate-Version}}.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-Introduction|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.}}
 
 
<b>Package Homepage:</b> ?
 
  
 
== Dependencies ==
 
== Dependencies ==
 
+
=== Required ===
 +
* [[popt]]
 
=== Recommended ===
 
=== Recommended ===
* [[Fcron]]
+
* [[Fcron]] or [[Vixie-Cron]]
  
 
== Non-Multilib ==
 
== Non-Multilib ==
Line 27: Line 26:
  
 
== Multilib ==
 
== Multilib ==
 +
'''''This package does not install any libraries so only one installation is needed.'''''
  
<b><i>This package does not provide any libraries so only one installation is required.</i></b>
+
=== 32bit ===
 
 
=== 32Bit ===
 
  
 
Compile the package:
 
Compile the package:
  
  make
+
  make CC="gcc ${BUILD32}"
  
 
Install the package:
 
Install the package:
Line 44: Line 42:
 
Compile the package:
 
Compile the package:
  
  make
+
  make CC="gcc ${BUILDN32}"
  
 
Install the package:
 
Install the package:
Line 50: Line 48:
 
  make install
 
  make install
  
=== 64Bit ===
+
=== 64bit ===
  
 
Compile the package:
 
Compile the package:
  
  make
+
  make CC="gcc ${BUILD64}"
  
 
Install the package:
 
Install the package:
Line 137: Line 135:
 
|is a utility that rotates and optionally compresses old log files.
 
|is a utility that rotates and optionally compresses old log files.
 
|}
 
|}
 +
 +
[[Category:General Utilities]]

Latest revision as of 08:17, 13 May 2010

Download Source: http://cross-lfs.org/~cosmo/wiki_files/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.

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.