Linux

已壓縮和未壓縮的日誌

  • December 12, 2018

最近我更改了letsencrypt的日誌配置,因為沒有給定的,而且我有文件:

letsencrypt.log
letsencrypt.log.1
letsencrypt.log.10
letsencrypt.log.10.gz
letsencrypt.log.11
letsencrypt.log.11.gz
letsencrypt.log.12
letsencrypt.log.12.gz
letsencrypt.log.13
letsencrypt.log.13.gz
letsencrypt.log.14
letsencrypt.log.14.gz
letsencrypt.log.15
letsencrypt.log.15.gz
letsencrypt.log.16
letsencrypt.log.16.gz

其中偶數文件有 1409 個字節,奇數文件有 0 個字節。然而,Gzipped 文件有一些內容(不同)。日誌輪換的配置是:

/var/log/letsencrypt/*.log {
   daily
   rotate 32
   compress
   delaycompress
   missingok
   notifempty
   create 644 root root
}

我應該如何將日誌輪換配置更改為僅保留:

  1. 前兩個文件未壓縮,
  2. gzip壓縮的其余文件,
  3. 擺脫空文件?

好的,所以我設法使正確的日誌輪換:

/var/log/letsencrypt/*.log {
   weekly
   rotate 9
   compress
   delaycompress
   missingok
   create 644 root root
}

所以不同的是我已經刪除了notifempty.

引用自:https://unix.stackexchange.com/questions/486744