这是来自logrotate手册页.
olddir directory
Logs are moved into directory for rotation. **The directory must be on the
same physical device as the log file being rotated**,and is assumed to be
relative to the directory holding the log file unless an absolute path
name is specified. When this option is used all old versions of the log
end up in directory. This option may be overridden by the noolddir
option.
olddir在同一物理设备上的存在是有限的.
可以使用以下解决方法.
将olddir设置为同一物理磁盘中的目录,并使用postrotate脚本将olddir的内容移动到不同物理设备上的目录.
示例logrotate配置文件:
/var/log/httpd/*log {
copytruncate
olddir /var/log/httpd/olddir
rotate 5
missingok
notifempty
sharedscripts
delaycompress
postrotate
mv /var/log/httpd/olddir/* /vagrant/httpd/olddir/
/sbin/service httpd reload > /dev/null 2>/dev/null || true
endscript
}