LoginSignup
1
1

More than 1 year has passed since last update.

/var/log/lastlog は logrotate しない

Last updated at Posted at 2022-02-12

タイトルの通りなのですが、「lastlog roglotate」で Google 日本語検索すると、上位に logrotate してしまうブログがいくつか出てきてしまうため、注意喚起です。

lastlog について man ページには以下の記載があります。

NOTE The lastlog file is a database which contains info on the last login of each user. You should not rotate it. It is a sparse file, so its size on the disk is usually much smaller than the one shown by "ls -l" (which can indicate a really big file if you have in passwd users with a high UID). You can display its real size with "ls -s".

logrotate しないでください。/var/log/lastlog はスパースファイルなので、たいていの場合「ls -l」で表示されるサイズよりも実際のディスク使用量ははるかに小さいです。実際のサイズは「ls -s」で確認できます。とのことです。

(実際に試してみたところ、私の環境ではそこまで差がありませんでした)

# ls -lsh /var/log/lastlog
288K -rw-rw-r--. 1 root utmp 286K  2月 12 20:05 /var/log/lastlog

ちなみに、2022年2月現在、日本語の man には上記の情報が記載されていません。
そのせいもあってか、 logrotate されてしまっているブログ記事がしばしばあるのかもしれません。

この件から得られた教訓は2つです。

  • ブログを参考にする場合は、公式リファレンスで裏を取るようにしましょう。
  • リファレンスはできるだけ英語で読むようにしましょう。man -L C lastlog
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1