logrotate包含日志文件的整个目录

时间:2017-11-02 01:18:50

标签: linux unix logrotate

有没有办法使用logrotate我可以旋转整个目录并压缩它而不仅仅是特定目录中的文件?我尝试使用下面的配置进行实验,但这不起作用。给出以下错误消息:

配置:

/path/to/folder/test {
daily
rotate 5
missingok
compress
delaycompress
}

错误:

$logrotate -vf test.conf
reading config file test.conf
reading config info for /path/to/folder/test

Handling 1 logs

rotating pattern: /path/to/folder/test  forced from command line (5 
rotations)
empty log files are rotated, old logs are removed
error: error creating unique temp file: Permission denied

1 个答案:

答案 0 :(得分:0)

Logrotate仅对目录中的单个文件起作用,而不对整个目录作为单个实体起作用。最简单的解决方案是cronjob,该调用在该目录上调用诸如gzip之类的内容,然后根据需要移动/删除文件。