ログファイルを勝手にローテーションしてくれるlogrotateだが、オリジナルのアプリケーションのローテーション設定に不正がないかチェックするコマンド。実行結果の意味など、細かい説明は一旦端折っている。
あまり使わないがたまに使うので、備忘の為に記載する。
下記のように-dコマンドをつけてlogrotateコマンドを実行すれば良い。
|
$ logrotate -d 【設定ファイルのパス】 |
/etc/logrotate.conf には下記のように /etc/logrotate.d/以下の設定ファイルをincludeする記述がある為、設定ファイルのパスにこれを指定すると実際にローテーションされるファイル全ての妥当性をチェックすることとなる。
nginxのローテーションチェックを行うと下記のような出力となった。
|
$ logrotate -d /etc/logrotate.d/nginx reading config file /etc/logrotate.d/nginx reading config info for /var/log/nginx/*/*log Handling 1 logs rotating pattern: /var/log/nginx/*/*log after 1 days (10 rotations) empty log files are not rotated, old logs are removed considering log /var/log/nginx/xxxxx/access.log log does not need rotating considering log /var/log/nginx/xxxxx/error.log log does not need rotating not running postrotate script, since no logs were rotated |
試しに設定ファイルを下記のように不正な状態として実行してみる(2行目に余計な「a」を記述)。
|
/var/log/nginx/*/*log { a create 0664 nginx root : : } |
|
$ sudo logrotate -d /etc/logrotate.d/nginx reading config file /etc/logrotate.d/nginx reading config info for /var/log/nginx/*/*log error: /etc/logrotate.d/ngin:2 unknown option 'a' -- ignoring line |
エラーが検知される。