사용자 시스템 타이머에서 실행되는 다음과 같이 구성된 logrotate 서비스가 있습니다.
문제는 회전된 대상이 잘리지 않고 logrotate.conf에 지정된 크기 이상으로 커질 수 있다는 것입니다.
-rw-r--r-- 1 stephen stephen 14M 2023-06-04 08:15 monitor-iotop.log.1
-rw-r--r-- 1 stephen stephen 14M 2023-06-04 08:19 monitor-iotop.log
logrotate.conf
/mnt/ram/log/monitor-iotop.log {
size 500K
copytruncate
rotate 1
maxage 0
missingok
notifempty
su stephen stephen
}
시간제 노동자
[Unit]
Description=Logrotate Timer
[Timer]
OnCalendar=*:0/5
AccuracySec=1s
Unit=logrotate.service
[Install]
WantedBy=timers.target
제공하다:
[Unit]
Description=Logrotate Service
[Service]
ExecStart=/usr/sbin/logrotate -s /tmp/logrotate.state /hd2/projects/test/top/logrotate.conf
및 Journalctl -u logrotate.service
2023-05-22T00:00:00.443993-0700 meer systemd[1]: Starting Rotate log files...
2023-05-22T00:00:00.484405-0700 meer systemd[1]: logrotate.service: Deactivated successfully.
2023-05-22T00:00:00.513788-0700 meer systemd[1]: Finished Rotate log files.
2023-05-23T00:00:00.478533-0700 meer systemd[1]: Starting Rotate log files...
2023-05-23T00:00:00.506664-0700 meer systemd[1]: logrotate.service: Deactivated successfully.
2023-05-23T00:00:00.528445-0700 meer systemd[1]: Finished Rotate log files.
2023-05-24T00:00:00.433292-0700 meer systemd[1]: Starting Rotate log files...
2023-05-24T00:00:00.468817-0700 meer systemd[1]: logrotate.service: Deactivated successfully.
2023-05-24T00:00:00.496690-0700 meer systemd[1]: Finished Rotate log files.