I discovered that using wildcard with logrotate give me empty files. I would like to find a solution for not having those empty files created. Many thanks for your help

The extract of my


/Data/logs/localhost_* {
     rotate 7
     size 10M
     maxage 15

When i run

/usr/sbin/logrotate /etc/logrotate.conf

du -sh ./*
1020K   ./catalina.out
13M     ./catalina.out-20191114.gz
84K     ./localhost.2019-10-30.log
2,9M    ./localhost_access_log2019-09-30.txt-14112019-20191115.gz
3,1M    ./localhost_access_log2019-11-06.txt-20191115.gz
3,0M    ./localhost_access_log2019-11-07.txt-20191115.gz
3,0M    ./localhost_access_log2019-11-08.txt-20191115.gz
3,0M    ./localhost_access_log2019-11-09.txt-20191115.gz
3,0M    ./localhost_access_log2019-11-10.txt-20191115.gz
3,0M    ./localhost_access_log2019-11-11.txt-20191115.gz
3,0M    ./localhost_access_log2019-11-12.txt-20191115.gz
3,0M    ./localhost_access_log2019-11-13.txt-20191115.gz
3,0M    ./localhost_access_log2019-11-14.txt-20191115.gz
0       ./localhost_access_log2019-11-15.txt
1,1M    ./localhost_access_log2019-11-15.txt-20191115.gz
2,1M    ./localhost_access_log2019-11-15.txt-20191119.gz
0       ./localhost_access_log2019-11-16.txt
3,1M    ./localhost_access_log2019-11-16.txt-20191119.gz
0       ./localhost_access_log2019-11-17.txt
3,1M    ./localhost_access_log2019-11-17.txt-20191119.gz
0       ./localhost_access_log2019-11-18.txt
3,4M    ./localhost_access_log2019-11-18.txt-20191119.gz
152K    ./localhost_access_log2019-11-19.txt
1,3M    ./localhost_access_log2019-11-19.txt-20191119.gz
  • Are you sure logrotate is the one creating those files? Looking at your file names, you're already rotating logs. Compressed files belong to logrotate. txt files do not. – SYN Nov 19 at 15:06
  • Logrotate is supposed to create empty files after rotating. That's part of it's normal function. I believe you can disable this behavior with nocreate (see man logrotate). As @SYN points out you appear to be rotating twice, once with logrotate and once with something else. – Philip Couling Nov 19 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.