CentOS7をAlmaLinux8に移行したらlogrotateでエラー発生

スポンサーリンク
スポンサーリンク

現状

CentOS7を移行ツール「Elevate」でAlmaLinux8に移行したらlogrotateでエラーが発生しました。

error: /etc/logrotate.conf:22 duplicate log entry for /var/log/wtmp
error: /etc/logrotate.conf:29 duplicate log entry for /var/log/btmp

「/etc/logrotate.conf」の22行目と29行目でそれぞれ重複のエラーが出ているようです。

# 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 { ←この辺がエラー1
monthly
create 0664 root utmp
minsize 1M
rotate 1
}

/var/log/btmp { ←この辺がエラー2
missingok
monthly
create 0600 root utmp
rotate 1
}

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

logrotateのテスト実行

ちなみに、logrotate.confのテストはlogrotateコマンドにd(デバッグモード)とv(詳細表示)オプションを付けて↓のコマンドで出来ます。

$ logrotate -dv /etc/logrotate.conf

調べた結果

Googleでいろいろ検索した結果、次の結論に至りました。

移行したAlmaLinux8でlogrotateのバージョンを確認すると「logrotate 3.14.0」でした。3.14.0の初期状態の「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

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

「logrotate 3.14.0」では「/etc/logrotate.conf」に「wtmp」と「btmp」についての定義がありません。その代わり、「/etc/logrotate.d/」にそれぞれ定義ファイルが存在しているようです。このため重複エラーが出ていたようです。

「/etc/logrotate.conf」から「wtmp」「btmp」の定義をコメント化してテスト実行したところエラーが出なくなったのでこれで解決としました。

コメント

タイトルとURLをコピーしました