Linux

logrotate 使用所有 CPU 電源

  • August 9, 2016

我有預設的 Debian 8.5 Jessie/etc/logrotate.conf內容:

# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create

# uncomment this if you want your log files compressed
#compress

# packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp, or btmp -- we'll rotate them here
/var/log/wtmp {
   missingok
   monthly
   create 0664 root utmp
   rotate 1
}

/var/log/btmp {
   missingok
   monthly
   create 0660 root utmp
   rotate 1
}

# system-specific logs may be configured here

使用此設置logrotate可以很好地完成工作。但是,如果我改變:

rotate 4

不同的東西,例如:

rotate 5

logrotate從來沒有完成它的工作,消耗了所有的 CPU 能力,所以我最終不得不終止它的程序。

這是為什麼?調整時我應該改變一些東西rotate嗎?

嘗試尋找一些命令來解析/調試 logrotate 配置而不實際應用它。

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.conf

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