logrotate is program to manage log. It will compress old log and delete the very old log (we define what make log “very old”).

In order to install it on Debian base system:
apt-get install logrotate

In rpm based system
yum install logrotate

The configuration file is /etc/logrotate.conf
In order to modularized  the configuration, we include the following line in the file:
include /etc/logrotate.d

Now all configuration file in the the directory /etc/logrotate.d will be included.

The structure is following:

<timeOption weekly|daily|monthly>
rotate <numberOfRotation>
size <minimumSizeInMegaByte>M

The compress option tell logrotate to compress the log file. delaycompress  tell the rotate the recent log is an exception and should not be rotated.

If we want to run the logrotate for a specific configuration file immediately, we can:
logrotate -d <fullPathToFile>

we can use the dateext to give the rotated log file name the date stamp.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s