logrotate daily+maxsize は回転しません。

logrotate daily+maxsize は回転しません。

CentOS 7.4とlogrotate 3.8.6をインストールしました。/etc/logrotate.d/同じシステムにインストールされているTomcatのいくつかのログ(例:catalina.out)を回転させるカスタムlogrotateファイルがあります。

/opt/test/apache-tomcat-8.5.15-client/logs/catalina.out {
copytruncate
daily
rotate 30 
olddir /opt/test/apache-tomcat-8.5.15-client/logs/backup
compress
missingok
maxsize 50M
dateext
dateformat .%Y-%m-%d
}

毎日またはサイズが50MBに達したら、ログを交換したいと思います。この場合、ログファイルは圧縮されてバックアップフォルダにコピーされ、削除されるまで30日間保存されます。

次のコマンドを使用してデバッグモードでlogrotateを手動で実行しましたが、エラーは表示されませんでした(そして予想される圧縮ログファイルが生成されました)。

/usr/sbin/logrotate -d /etc/logrotate.d/openncp-tomcat-backoffice 2> /tmp/logrotate.debug

問題がなければ、/var/lib/logrotate/logrotate.statusファイルは回転しているように見えますが、そうではありません。

"/var/log/yum.log" 2017-11-27-19:0:0
"/opt/test/apache-tomcat-8.5.15-server/logs/catalina.out" 2017-12-15-3:41:1
"/var/log/boot.log" 2017-12-15-3:41:1
"/var/log/up2date" 2017-11-27-19:0:0

デフォルトは次のとおりです/etc/logrotate.conf

# 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

# use date as a suffix of the rotated file
dateext

# 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 and btmp -- we'll rotate them here
/var/log/wtmp {
    monthly
    create 0664 root utmp
        minsize 1M
    rotate 1
}

/var/log/btmp {
    missingok
    monthly
    create 0600 root utmp
    rotate 1
}

# system-specific logs may be also be configured here.

私も基本的なものを持っています/etc/cron.daily/logrotate

#!/bin/sh

/usr/sbin/logrotate -s /var/lib/logrotate/logrotate.status /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
    /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0

~によるとlogrotate マンページ:

maxsize size
    Log files are rotated when they grow bigger than size bytes even before the additionally specified time interval ( daily, weekly, monthly, or yearly). The related size option is similar except that it is mutually exclusive with the time interval options, and it causes log files to be rotated without regard for the last rotation time. When maxsize is used, both the size and timestamp of a log file are considered. 

これまでのログが50MBに達しておらず、数日間循環がないことを確認しました。

正しく設定する方法についての指示を求めます。

ベストアンサー1

この問題は、/var/logとは異なるディレクトリにあるSELinuxファイルタイプのログファイルに関連しています。これは、logrotateプロセスにその操作を実行する権限がないことを意味します。私は別のものを見つけました。だからスレッドこのレッドハットページこれは問題を解決するのに役立ちます。 Redhatのドキュメントが非常に役に立つと思い、ここに2つのリンクを含めました。

おすすめ記事