How can I rotate many log files into a different subdirectory per rotation?
You should be able to call an external script in the postrotate
directive:
postrotate
/path/to/your.sh
endscript
and have that script do the moving, e.g.:
#!/bin/bash
newdir=/var/log/example/`date +%Y%m%d`
mkdir $newdir
mv /var/log/example.1.gz $newdir
find /var/log/example -mindepth 1 -maxdepth 1 -mtime +7 \
-type d -print0 | xargs -0 rm -rf
However, it might be easier to just use the dateext
directive. With that the rotated files will be appended with a timestamp (although not moved to a different directory).
See logrotate(8)
for details about both directives.