我正在尝试设置 logrotate,但由于某些原因 logrotate 不旋转文件。它总是抱怨找不到以前的日志文件。
下面是我的 logrotate 文件的内容:
/home/cm/dummy.log{
rotate 4
size 5K
copytruncate
delaycompress
compress
missingok
}
运行以下命令
logrotate -v /etc/logrotate.d/dummy
返回以下输出:
Allocating hash table for state file, size 15360 B
Handling 1 logs
rotating pattern: /home/cm/dummy.log 5120 bytes (4 rotations)
empty log files are rotated, old logs are removed
switching euid to 1000 and egid to 1000
considering log /home/cm/dummy.log
log needs rotating
rotating log /home/cm/dummy.log, log->rotateCount is 4
dateext suffix '-20200327'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
previous log /home/cm/dummy.log.1 does not exist
renaming /home/cm/dummy.log.4.gz to /home/cm/dummy.log.5.gz (rotatecount 4, logstart 1, i 4),
old log /home/cm/dummy.log.4.gz does not exist
renaming /home/cm/dummy.log.3.gz to /home/cm/dummy.log.4.gz (rotatecount 4, logstart 1, i 3),
old log /home/cm/dummy.log.3.gz does not exist
renaming /home/cm/dummy.log.2.gz to /home/cm/dummy.log.3.gz (rotatecount 4, logstart 1, i 2),
old log /home/cm/dummy.log.2.gz does not exist
renaming /home/cm/dummy.log.1.gz to /home/cm/dummy.log.2.gz (rotatecount 4, logstart 1, i 1),
old log /home/cm/dummy.log.1.gz does not exist
renaming /home/cm/dummy.log.0.gz to /home/cm/dummy.log.1.gz (rotatecount 4, logstart 1, i 0),
old log /home/cm/dummy.log.0.gz does not exist
log /home/cm/dummy.log.5.gz doesn't exist -- won't try to dispose of it
copying /home/cm/dummy.log to /home/cm/dummy.log.1
set default create context to system_u:object_r:user_home_t:s0
truncating /home/cm/dummy.log
switching euid to 0 and egid to 0
set default create context
当我运行此命令后检查文件夹时,我有一个名为:dummy.log.1 的文件,其内容与旋转之前完全相同,并且有一个空的 dummy.log 文件。
有人知道我缺少什么吗?