logrotateが期待どおりに機能しない

logrotateが期待どおりに機能しない

ユーザーシステムタイマーで実行される次のように構成された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.

ベストアンサー1

おすすめ記事