logrotate 不压缩文件

logrotate 不压缩文件

我遇到了 logrotate 问题,因为它不压缩文件。我们从 Centos 7 迁移到 Alma Linux,但它不起作用。我正在尝试让 logrotate 轮换和压缩 /var/log/cisco 中的日志文件。 Logrotate 成功旋转日志并将日期附加到文件名。这是 /etc/logrotate.d/cisco_syslog 中的配置

/var/log/cisco/* {
notifempty
weekly
olddir old
rotate 12
compress
create
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    /usr/bin/systemctl restart tail_aggregate.service 2> /dev/null
endscript }

来自 /var/log/messages 的错误消息

Feb 13 03:50:40 management logrotate: ALERT exited abnormally with [1]

当我像这样在调试中运行 logrotate 时

logrotate -d -v /etc/logrotate.d/cisco_syslog --force

它成功尝试压缩文件

compressing log with: /bin/gzip
compressing log with: /bin/gzip
compressing log with: /bin/gzip
compressing log with: /bin/gzip
compressing log with: /bin/gzip
compressing log with: /bin/gzip
compressing log with: /bin/gzip
compressing log with: /bin/gzip
compressing log with: /bin/gzip
compressing log with: /bin/gzip
compressing log with: /bin/gzip
compressing log with: /bin/gzip

gzip 已安装,我可以手动压缩文件。

编辑:sestatus 的输出

SELinux status:                 disabled

ausearch -ts 今天的输出 -m avc -i

<no matches>

ls -laZ /var/log/cisco 的输出

输出

出于安全原因,文件名被隐藏。

/etc/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

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

日志轮转版本

logrotate 3.14.0

相关内容