I used logrotate in centos6 so far, but I made a note because there was a stumbling point when I implemented it in centos8.
When implemented in centos8, the file is rotated, but the data is not rotated.
(Example) ➀ The logrotate file in /etc/cron.daily starts every minute (calls /etc/logrotate.conf) ↓ ➁ The /etc/logrotate.conf configuration file is read (daily runs the file in the /etc/logrotate.d directory) ↓ There is a syslog file in /etc/logrotate.d. Describe the path of the file you want to rotate in syslog. ↓ The specified file is rotated.
In centos8, there is a syslog.rpmnew file in the directory /etc/logrotate.d that centos6 did not have. If the contents of two files, syslog and syslog.rpmnew, are duplicated in the logrotate.d directory, they will not be rotated properly. It is necessary to avoid duplication of contents.
systemctl restart rsyslog.service
systemctl enable rsyslog.service
Forcibly rotate with the -f option to check if it is rotating properly.
logrotate -f /etc/logrotate.conf
Complete if the data is successfully rotated.
Recommended Posts