I am trying to implement log rotate in my streaming job. This is my test config file.
/home/hadoop/first* {
daily
rotate 3
size 1M
compress
delaycompress
}
When I try to run logrotate, all that happens is the log file first_run.out is appended with .1 file is not split and zip does not happen to the split file.
Edit: When I try using -v option, I get this log
[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
The syntax is correct.
Maybe your file size is less than 1 MB?
Use the key -v
, it help you for solve the problem. Eg: logrotate -v logrotateconfig.file
UPD: your namefile generates recursion for 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
....
Necessary to more precisely specify the filename in the logrotate configuration.