我正在尝试在我的流媒体作业中实现日志轮播。这是我的测试配置文件。
/home/hadoop/first* {
daily
rotate 3
size 1M
compress
delaycompress
}
当我尝试运行logrotate时,所有发生的事情都是日志文件first_run.out附加.1文件没有拆分,并且zip不会发生在拆分文件中。
编辑:当我尝试使用-v选项时,我得到了这个日志
[hadoop@ip-10-27-90-253 ~]$ sudo logrotate -vf /etc/logrotate.d/apache2.conf
reading config file /etc/logrotate.d/apache2.conf
reading config info for /home/hadoop/first*
Handling 1 logs
rotating pattern: /home/hadoop/first* forced from command line (3 rotations)
empty log files are rotated, old logs are removed
considering log /home/hadoop/first_run.out.1.1.1.1.1.1
log needs rotating
rotating log /home/hadoop/first_run.out.1.1.1.1.1.1, log->rotateCount is 3
dateext suffix '-20190411'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
previous log /home/hadoop/first_run.out.1.1.1.1.1.1.1 does not exist
renaming /home/hadoop/first_run.out.1.1.1.1.1.1.3.gz to /home/hadoop/first_run.out.1.1.1.1.1.1.4.gz (rotatecount 3, logstart 1, i 3),
old log /home/hadoop/first_run.out.1.1.1.1.1.1.3.gz does not exist
renaming /home/hadoop/first_run.out.1.1.1.1.1.1.2.gz to /home/hadoop/first_run.out.1.1.1.1.1.1.3.gz (rotatecount 3, logstart 1, i 2),
old log /home/hadoop/first_run.out.1.1.1.1.1.1.2.gz does not exist
renaming /home/hadoop/first_run.out.1.1.1.1.1.1.1.gz to /home/hadoop/first_run.out.1.1.1.1.1.1.2.gz (rotatecount 3, logstart 1, i 1),
old log /home/hadoop/first_run.out.1.1.1.1.1.1.1.gz does not exist
renaming /home/hadoop/first_run.out.1.1.1.1.1.1.0.gz to /home/hadoop/first_run.out.1.1.1.1.1.1.1.gz (rotatecount 3, logstart 1, i 0),
old log /home/hadoop/first_run.out.1.1.1.1.1.1.0.gz does not exist
log /home/hadoop/first_run.out.1.1.1.1.1.1.4.gz doesn't exist -- won't try to dispose of it
renaming /home/hadoop/first_run.out.1.1.1.1.1.1 to /home/hadoop/first_run.out.1.1.1.1.1.1.1
语法是正确的。
也许你的文件大小不到1 MB?
使用密钥-v
,它可以帮助您解决问题。例如:logrotate -v logrotateconfig.file
UPD:您的namefile为logrotate生成递归。
first_run.out.1.1.1.1.1.1.1
first_run.out.1.1.1.1.1.1.1.1
first_run.out.1.1.1.1.1.1.1.1.1
....
必须在logrotate配置中更精确地指定文件名。