gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:11:13 28 4
gpt4 key购买 nike

我需要你的帮助来理解 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com