Article Title: linux system logs are not automatically split. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Logs under/var/log are split into logs every seven days. The original logs are named xxx.1 and are automatically deleted after one month. However, some servers do not split logs.
Solution
Log splitting is completed by/etc/cron. daily/logrotate. The configuration file is:
/Etc/logrotate. conf
The content is as follows:
-----------------?
# See "man logrotate" for details
# Rotate log files weekly
Weekly
# Keep 4 weeks worth of backlogs
Rotate 4
# Create new (empty) log files after rotating old ones
Create
# Uncomment this if you want your log files compressed
# Compress
# RPM packages drop log rotation information into this directory
Include/etc/logrotate. d
# No packages own wtmp-we'll rotate them here
/Var/log/wtmp {
Monthly
Create 0664 root utmp
Rotate 1
}
# System-specific logs may be also be configured here.
-----------------?
This file specifies parameters such as the split cycle. The specific splitting of each log is completed by the script in the/etc/logrotate. d directory. This directory contains log files of several services, such as apache, mysql, and resin. (The/var/log/maillog of the email is written to the system using syslog)
Run/etc/cron. daily/logrotate manually to see what errors are reported.
Example: report
Error: httpd: 1 duplicate log entry for/var/log/httpd/access_log
This is because duplicate projects exist in the/etc/logrotate. d directory. After checking that the user has installed httpd rpm on his own, there are two directory segmentation projects apache and httpd under the etc/logrotate. d directory, which causes logrotate to fail to run.
Solution: remove the/etc/logrotate. d/httpd file. We recommend that you check for redundant log splitting items based on a clean server.