我有一组日志文件(它们相关,但属于应用程序级别,不相关)。我想logrotate
在 Debian Linux 上设置配置,一旦其中任何一个达到限制(例如 100MB),就轮换整个组(所有文件)。我看不到这样的选项 - 有想法如何实现吗?
答案1
我最终得到了自己的脚本来触发forced
模式下的 logrotate。
答案2
重击:man logrotate.conf
文件选择
missingok
If the log file is missing, go on to the next one without issuing an error message. See also nomissingok.
nomissingok
If a log file does not exist, issue an error. This is the default.
ifempty
Rotate the log file even if it is empty, overriding the notifempty option (ifempty is the default).
notifempty
Do not rotate the log if it is empty (this overrides the ifempty option).
minage count
Do not rotate logs which are less than <count> days old.
maxage count
Remove rotated logs older than <count> days. The age is only checked if the logfile is to be rotated. rotate -1 does not hinder removal. The files are mailed to the configured address if maillast and mail are configured.
minsize size
Log files are rotated when they grow bigger than size bytes, but not before the additionally specified time interval (daily, weekly, monthly, or yearly). The related size option is similar except that it is mutually exclusive with the time interval options, and it
causes log files to be rotated without regard for the last rotation time, if specified after the time criteria (the last specified option takes the precedence). When minsize is used, both the size and timestamp of a log file are considered.
maxsize size
Log files are rotated when they grow bigger than size bytes even before the additionally specified time interval (daily, weekly, monthly, or yearly). The related size option is similar except that it is mutually exclusive with the time interval options, and it causes
log files to be rotated without regard for the last rotation time, if specified after the time criteria (the last specified option takes the precedence). When maxsize is used, both the size and timestamp of a log file are considered.
来源 1:Debian Bullseye“man”命令
来源 2:https://linux.die.net/man/8/logrotate
以上确实包含单个文件,同时也用于完整的子目录
完整示例
在这里你决定,什么,一个文件,一堆.log 或 /任何
/var/log/folder/*.log { minsize 10M maxsize 50M }
/var/log/folder/single.log { minsize 10M maxsize 50M }
/var/log/folder/* { minsize 10M maxsize 50M }
我想这将解决你的所有问题。