ログ循環が機能しないのはなぜですか?

ログ循環が機能しないのはなぜですか?

毎日アプリケーションのログを交換しようとしていますが、未知の理由で機能しません。 logrotate 定義をデバッグすると回転しないと言います。しかし、強制的に回転させる場合にのみ機能します。

私がここで何を見逃しているのでしょうか?

logrotate 定義 (/etc/logrotate.d/application)

/tmp/company.0000/application.log {
  daily
  rotate 7
  compress
  copytruncate
  missingok
  extension .log
  dateext
  dateformat _%Y%m%d
  su root valter
  create 440 valter valter
}

フォルダ内のすべてのアイテムを一覧表示

valter@eniac:~$ ls -ltha /tmp/company.0000/
total 2,8M
drwxrwxrwx 9 root   root    96K Aug 30 17:25 ..
drwxrwxr-x 2 valter valter 4,0K Aug 30 17:25 .
-rw-rw-r-- 1 valter valter 2,7M Aug 30 17:00 application.log

変更されたファイル日付

valter@eniac:~$ sudo touch -m --date="2016-08-01" /tmp/company.0000/application.log
valter@eniac:~$ ls -ltha /tmp/company.0000/
total 2,8M
drwxrwxrwx 9 root   root    96K Aug 30 17:25 ..
drwxrwxr-x 2 valter valter 4,0K Aug 30 17:25 .
-rw-rw-r-- 1 valter valter 2,7M Aug  1 00:00 application.log

ログ自体を変更せずにlogrotateのデバッグ

valter@eniac:~$ sudo logrotate -d /etc/logrotate.d/application 
reading config file /etc/logrotate.d/application
extension is now .log

Handling 1 logs

rotating pattern: /tmp/company.0000/application.log  after 1 days (7 rotations)
empty log files are rotated, old logs are removed
switching euid to 0 and egid to 1000
considering log /tmp/company.0000/application.log
  log does not need rotating
switching euid to 0 and egid to 0

強制ログの回転とリスト

valter@eniac:~$ sudo logrotate --force /etc/logrotate.d/application 
valter@eniac:~$ ls -ltha /tmp/company.0000/
total 264K
drwxrwxr-x 2 valter valter 4,0K Aug 30 17:26 .
-rw-rw-r-- 1 valter valter    0 Aug 30 17:26 application.log
drwxrwxrwx 9 root   root    96K Aug 30 17:25 ..
-rw-rw-r-- 1 valter valter 158K Aug  1 00:00 application_20160830.log.gz

ベストアンサー1

おすすめ記事