LOGROTATE

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
weekly

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

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

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

# Make compressed log file while create new log rotate file
compress

# 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 {
monthly
create 0664 root utmp
minsize 1M
rotate 1
}
/var/log/btmp {
missingok
monthly
create 0600 root utmp
rotate 1
}
# system-specific logs may be also be configured here.
:wq

 

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

 




Leave a Reply

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