logrotateの構文を確認するには?

logrotateの構文を確認するには?

/etc/logrotate.d/FOO ファイルにタイプミスがあると思われます。

これをどのように確認しますか?これまで、私は次のことがわかります。

https://linux.die.net/man/8/logrotate

おそらくこれ? :

logrotate -df /etc/logrotate.d/FOO 2>&1 | grep -i error

ベストアンサー1

私は現在の回答に対するVladのコメントに同意します。安全な方法実際には何も回転せずに構文を確認してください。はい、デバッグオプションを使用してください。

からman logrotate

       -d, --debug
              Turns  on  debug  mode  and implies -v.  In
              debug mode, no changes will be made to  the
              logs or to the logrotate state file.

マイコンピュータの例:

$ logrotate -d /etc/logrotate.d/httpd 
reading config file /etc/logrotate.d/httpd

Handling 1 logs

rotating pattern: /var/log/httpd/*_log  5242880 bytes (10 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/httpd/access_log
  log does not need rotating
considering log /var/log/httpd/error_log
  log does not need rotating
not running postrotate script, since no logs were rotated

この-fオプションを追加すると、回転が強制されます。実際に実行(必要かどうかにかかわらず)さらなる分析が可能です。

要約:

-d    Just debug, don't actually rotate.
-df   Actually perform rotation and debug (includes verify).
-vf   Actually perform rotation and just verify.

おすすめ記事