Log rotate is used to rotate the log file. We can rotate the log file by daily, weekly, monthly, yearly. We can send the log file to mail.

Config file:

/etc/logrotate.conf    ====> System main log rotation file. Log rotation configuration for all the server log files are specified in this file.

/etc/logrotate.d/         ====> Installed package’s log rotate config file store in this path.
In that means if  RPM package contain log rotation script for that particular package it  will store under this path, /etc/logrotate.d/

# vim /etc/logrotate.conf
Edit config and details are show below,

# rotate log files weekly  daily,  monthly or yearly

# keep No of weeks log files worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones

# Set date in file name while create new log rotate file.

# Make compressed log file while create new log rotate file

# Make file by date format. We should give this order. We can use `-` or `/ `
dateformat -%Y-%M-%D

# send log rotate file to mail
mail  abc@123.com

# Make log rotate by file size, we use parameter like k,M,G. k = kb,M= mb, G=Gb
size  “size ie 30k,2M,1G”

# Use RPM package’s log rotate script
include /etc/logrotate.d

# no packages own wtmp and btmp — we’ll rotate them here
/var/log/wtmp {
create 0664 root utmp
minsize 1M
rotate 1
/var/log/btmp {
create 0600 root utmp
rotate 1
# system-specific logs may be also be configured here.


=============================> Blass <============================


Leave a Reply

Your email address will not be published. Required fields are marked *