linux - 在多个地方定义的规则的 Logrotate 行为

标签 linux logrotate

我需要你的帮助来理解 logrotate 行为。

logrotate.conf:

# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create

# use date as a suffix of the rotated file
dateext

# uncomment this if you want your log files compressed
#compress

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp and btmp -- we'll rotate them here
/var/log/wtmp {
    monthly
    create 0664 root utmp
    minsize 1M
    rotate 1
}

/var/log/btmp {
    missingok
    monthly
    create 0600 root utmp
    rotate 1
}

# system-specific logs may be also be configured here.

logrotate.d 目录中,我有一个名为 consul-log 的文件:

/var/log/consul {
    size 500M
    missingok
    rotate 0
    compress
    notifempty
    copytruncate
}    

/var/lib/logrotate.status 文件中,我可以看到这些行(与 consul 日志文件相关):

logrotate state -- version 2
"/var/log/consul" 2016-1-25

我的问题是:

  1. 如果我在 logrotate.conf 中有 rotate 4,但在 logrotate.d/consul-log 中有 rotate 0 ,logrotate 会使用rotate 0 还是rotate 4

最佳答案

关于你的问题:

If I have rotate 4 inside logrotate.conf, but I have rotate 0 inside logrotate.d/consul-log, will logrotate use rotate 0 or rotate 4?

logrotate.conf 是系统范围更改的配置文件,您在 logrotate.d 文件夹中创建的任何其他配置文件都将被覆盖。

因为这个指令:

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

关于linux - 在多个地方定义的规则的 Logrotate 行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36692644/

相关文章:

ruby - 如何获取某个进程正在读取的打开文件的文件指针位置?

Python IRC 机器人帮助

linux - 在树莓派上使用logrotate和syslog-ng(如何删除旧日志?)

python - 为什么 python 日志模块旋转日日志会困惑?

ruby - 生产中的 redis 和 resque

android - 如何从头开始编写 Android 平板电脑的 LCD 驱动程序?

linux - 如何在 Linux 中只提取文件的 inode 编号?

ansible - 运行 ansible 剧本时出现模糊弃用错误

cron - ProFTPD被杀死(信号15)错误-如何修复logrotate重新启动错误?

java - 如何在 Java 或其他平台中创建一个 logrotate 友好的文件编写器?