- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我的 CentOS 7.4 安装了 logrotate 3.8.6。我在 /etc/logrotate.d/
下有一个自定义 logrotate 文件,用于轮换安装在同一台机器上的 Tomcat(例如,catalina.out)上的一些日志。
/opt/test/apache-tomcat-8.5.15-client/logs/catalina.out {
copytruncate
daily
rotate 30
olddir /opt/test/apache-tomcat-8.5.15-client/logs/backup
compress
missingok
maxsize 50M
dateext
dateformat .%Y-%m-%d
}
我希望日志每天轮换一次,或者在大小达到 50MB 时轮换一次。发生这种情况时,日志文件会被压缩并复制到备份文件夹中,并在删除前保留 30 天。
我已经使用以下命令在 Debug模式下手动运行了 logrotate,并且没有显示任何错误(并且创建了预期的压缩日志文件):
/usr/sbin/logrotate -d/etc/logrotate.d/openncp-tomcat-backoffice 2>/tmp/logrotate.debug
在 /var/lib/logrotate/logrotate.status
中没有问题,文件显示为已旋转但实际上并没有:
"/var/log/yum.log" 2017-11-27-19:0:0
"/opt/test/apache-tomcat-8.5.15-server/logs/catalina.out" 2017-12-15-3:41:1
"/var/log/boot.log" 2017-12-15-3:41:1
"/var/log/up2date" 2017-11-27-19:0:0
我有默认的/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
# 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.
我还有默认的/etc/cron.daily/logrotate
:
#!/bin/sh
/usr/sbin/logrotate -s /var/lib/logrotate/logrotate.status /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0
我请求您提供适当配置的指导。
最佳答案
问题与日志文件的 SELinux 文件类型有关,这些文件位于与/var/log 不同的目录中,这意味着 logrotate 进程无权执行其任务。我找到了另一个 SO thread还有这个Redhat page这有助于解决问题。我发现 Redhat 文档非常有用,所以我在这里提供了 2 个链接:
关于linux - Logrotate daily+maxsize不旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47838164/
我正在为某些 Web 应用程序编写自己的 logrotate 配置: /home/me/public_html/logs/*.log { daily missingok rot
我查看了 logrotate.conf 示例以及/etc/logrotate.d 目录中的所有内容。我无法在这些文件中找到有关变量的文档。 我正在尝试创建一个配置文件来轮换我们正在编写的应用程序的日志
我查看了手册页,在这里搜索,用谷歌搜索等等。 有人知道 logrotate 使用的默认大小吗? 您可以引用什么引用来说明默认大小? 我知道我可以在我的配置文件中专门设置大小。 最佳答案 没有默认大小,
我查看了手册页,在这里搜索,用谷歌搜索等等。 有人知道 logrotate 使用的默认大小吗? 您可以引用什么引用来说明默认大小? 我知道我可以在我的配置文件中专门设置大小。 最佳答案 没有默认大小,
我正在使用 logrotate,我可以看到我通过包管理器安装的东西在这里安装了东西: /etc/logrotate.d/ 例如我有文件 nginx其中包含这个 /var/log/nginx/*.log
//, 这个问题有点模棱两可。 场景如下: 我有以下三个扩展名的日志,但我当前的规则仅适用于 *.log 文件: .1 .log .txt 另外,因为 Tomcat 正在轮换日志,所以我有以下内容:
因此,设置最大日志轮换大小似乎只有在 uwsgi.ini 而不是/etc/logrotate.d/uwsgi 中设置时才有效(即使使用/etc/logrotate.d/uwsgi 文件手动测试 log
我有一个自定义应用程序 (myApp),它正在将日志写入文件“/var/log/myApp”。我可以看到正在写入的日志并且它工作正常。现在我正在尝试为此文件设置 logrotate,为此我创建了一个配
CentOS v.7 Logrotate v.3.8.6 我将 logrotate 设置为在文件达到 5M 时旋转,但它会忽略它,如果我每天添加,无论大小如何,它都会每天旋转,我尝试使用 size、m
logrotate 没有旋转我的日志 要验证日志文件不为空: # ls -laFh /var/log/cisco-meraki.log -rw-r----- 1 root adm 2.8G Sep
我正在使用 logrotate管理我的日志。因为我必须管理一堆日志文件。我的 logrotate 配置看起来像 /log/typeA*.log /log/typeB*.log /log/typeC*.
我想使用 logrotate 来管理我的日志。我发现压缩选项非常有用。但是 gzip(默认压缩)对我的日志来说并不是最好的(实验上,其他压缩的效率可以提高两倍到五倍)。 是否可以更改压缩类型?我没有找
为什么 logrotate 会删除文件而不是旋转它? 这是配置: /var/log/httpd/*log { size 1G missingok notifempty
美好的一天! 我尝试使用 linux 的 logrotate 工具来轮换我的 tomcat 日志。我在/etc/logrotate.d下创建了一个名为tomcat的脚本 /path/to/tomcat
我正在尝试在 RHEL 中为 tomcat6 日志配置 logrotate。目前,logrotate 对 catalina.out 日志工作正常,它被正确地旋转和压缩。 问题在于其中包含日期的文件,例
我有一个每天运行一次的 logrotate 策略,因为它是 cron.daily 的一部分。我想在达到一定大小时触发文件的 logrotate。所以我正在寻找一种方法来使文件大小成为触发器,而不是每小
我有一组针对不同进程的特定日志。考虑 Log_name1.Date.0.log(当前日期最早的)-----> Log_name1.Date.1.log Log_name1.Date.2.log Log
我正在尝试在我的 Ubuntu 服务器上为 apache 设置 logrotate,但是在尝试测试轮换时我不断收到以下错误: logrotate_script: 4: logrotate_script
我有一个测试应用程序,它每小时运行一次,并在每次执行时使用唯一的日志文件。要清理日志,已设置以下 logrotate 配置: { # Daily rotation with 1 wee
我有一个 Rust 应用程序,它将日志重定向到某个目录。为了合并滚动策略,我正在使用 logrotate linux 实用程序。为此,我在/etc/logrotate.d 中创建了我的应用程序特定配置
我是一名优秀的程序员,十分优秀!