Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Is it possible to get logrotate to consider logfiles in a directory and all its subdirectories? (i.e. without explicitly listing the subdirectories.)

share|improve this question

1 Answer 1

up vote 27 down vote accepted

How deep do your subdirectories go?

/var/log/basedir/*.log /var/log/basedir/*/*.log {
    rotate 5

Will rotate all .log files in basedir/ as well as all .log files in any direct child of basedir. If you also need to go 1 level deeper just add another /var/log/basedir/*/*/*.log until you have each level covered.

This can be tested by using a separate logrotate config file which contains a constraint that will not be met (a high minsize) and then running log rotate yourself in verbose mode

logrotate -d testconfig.conf

the -d flag will list each log file it is considering to rotate.

share|improve this answer
Thanks! Looks like -d puts logrotate in dry run mode (i.e. doesn't actually change anything) actually. –  ithinkihaveacat Dec 3 '10 at 15:36
Ah, that is even better! –  Dan R Dec 3 '10 at 16:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.