AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 785469
Accepted
tmedtcom
tmedtcom
Asked: 2024-10-22 18:29:06 +0800 CST2024-10-22 18:29:06 +0800 CST 2024-10-22 18:29:06 +0800 CST

用于 freeradius 会计日志的 Logrotate

  • 772

我有此日志详细信息配置:

/opt/freeradius/logs/*/detail {

daily
rotate 4
compress
delaycompress
missingok
notifempty
create 0640 root root
sharedscripts
maxsize 500M
postrotate
    /bin/systemctl reload freeradius > /dev/null 2>/dev/null || true
endscript
}

我有这些旧日志和新日志:

[root@freeradius01 192.168.17.10]# pwd
/opt/freeradius/logs/192.168.17.10
[root@freeradius01 192.168.17.10]# ll
total 56919724
-rwxrwxrwx 1 root root 21048752215 Aug 14 23:59 detail-20240814
-rwxrwxrwx 1 root root 21617187765 Aug 15 23:59 detail-20240815
-rwxrwxrwx 1 root root  5988044800 Aug 16 23:59 detail-20240816
-rwxrwxrwx 1 root root     5947392 Sep 25 23:59 detail-20240925
-rwxrwxrwx 1 root root  7478423552 Oct 21 23:59 detail-20241021
-rwxrwxrwx 1 root root  1907452140 Oct 22 11:19 detail-20241022
[root@freeradius01 192.168.17.10]#

当手动运行 logrotate 并强制使用 verbos 时,我得到以下结果:

[root@freeradius01 192.168.17.10]#  /usr/sbin/logrotate -v -f /etc/logrotate.d/radiusd
reading config file /etc/logrotate.d/radiusd
Reading state from file: /var/lib/logrotate/logrotate.status
Allocating hash table for state file, size 64 entries
Creating new state
Creating new state
Creating new state
..
..
Creating new state

Handling logs


rotating pattern: /opt/freeradius/logs/*/detail  forced from command line (4 rotations)
empty log files are not rotated, log files >= 524288000 are rotated earlier, old logs are removed
considering log /opt/freeradius/logs/*/detail
not running postrotate script, since no logs were rotated


[root@freeradius01 192.168.17.10]# ll
total 56919724
-rwxrwxrwx 1 root root 21048752215 Aug 14 23:59 detail-20240814
-rwxrwxrwx 1 root root 21617187765 Aug 15 23:59 detail-20240815
-rwxrwxrwx 1 root root  5988044800 Aug 16 23:59 detail-20240816
-rwxrwxrwx 1 root root     5947392 Sep 25 23:59 detail-20240925
-rwxrwxrwx 1 root root  7478423552 Oct 21 23:59 detail-20241021
-rwxrwxrwx 1 root root  1968389637 Oct 22 11:22 detail-20241022
[root@freeradius01 192.168.17.10]# grep "detail"   /var/lib/logrotate/logrotate.status
"/var/log/radius/radacct/*/detail" 2024-3-5-3:0:0
"/opt/freeradius/logs/*/detail" 2024-3-5-3:0:0
[root@freeradius01 192.168.17.10]# date
Tue Oct 22 11:22:45 WAT 2024
[root@freeradius01 192.168.17.10]#

因此,尽管我手动运行了日志轮换,但它并没有运行/而且旧日志也没有压缩!!?

cron
  • 1 1 个回答
  • 21 Views

1 个回答

  • Voted
  1. Best Answer
    meuh
    2024-10-24T01:00:54+08:002024-10-24T01:00:54+08:00

    当规则的模式与/opt/freeradius/logs/*/detail目录中的任何日志文件都不匹配时,logrotate则不执行任何操作。在这种情况下,您需要detail在目录中创建一个虚拟文件,/opt/freeradius/logs/192.168.17.10/然后尝试强制执行 logrotate。但您还需要notifempty从配置中暂时删除,并且不要在与已经存在的日期扩展相同的日期执行此操作-20241022,否则 logrotate 将中止,因为文件已经存在。

    • 2

相关问题

  • 如果 anacron 不是守护进程,它是如何工作的?

  • Cron 作业未按预期工作

  • Cron */6 小时但有偏移量?

  • 如何恢复已删除的 crontab

  • Auto-SSH 手动工作,但不在后台工作

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve