Brief introduction
Logging a variety of information program is running.
It can analyze user behavior through the log, running track record, look for procedural issues.
Unfortunately, disk space is limited
logging controversy like an airplane black box, and then record important information can only record what happened last period of time.
To save space and easy to organize, log files often need to press! Or time! Size and other dimensions into multiple copies, delete the old time log file.
The main configuration file
vim /etc/logrotate.conf
weekly: rotation cycle, a week rotation
rotate 4: Reserved 4 parts
create: Create a new file rotation
dateext: use the date as a suffix
#compress: whether to compress
include /etc/logrotate.d: contains sub-directory under the configuration file
Method of rotation of a log file settings
/ var / log / wtmp {
Monthly: January rotate once
minsize 1M: 1M only achieve the minimum rotation, Monthly and minSize
the Create 0664 root utmp: Creating a new file rotation, and set permissions
rotate 1: Keep a
}
/ var / log / btmp {
missingok: lost not prompt
monthly: once a month rotation
create 0600 root utmp: Creating a new file rotation, and set permissions
rotate 1: Keep a
}
Examples
Rotation of the target file /var/log/yum.log
配置轮转规则
# vim /etc/logrotate.d/yum
/var/log/yum.log {
missingok //丢失不执行
# notifempty //空文件不论转
# size 30k //达到30k轮转, daily or size
# yearly //或者一年一轮转
daily //缩小周期到1天
rotate 3 //轮转保留3次
create 0777 root root
}