我正在尝试在流作业中实现日志轮换。这是我的测试配置文件。
/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
答案 0 :(得分:0)
语法正确。
也许您的文件大小小于1 MB?
使用密钥-v
,可帮助您解决问题。例如:logrotate -v logrotateconfig.file
UPD:您的名称文件为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配置中更精确地指定文件名。