运维联盟俱乐部

 找回密码
 立即注册
查看: 2238|回复: 0

清空/var/log/journal日志

[复制链接]
  • TA的每日心情
    开心
    2023-8-9 11:05
  • 发表于 2020-6-2 01:08:10 | 显示全部楼层 |阅读模式
    1)只保留近一周的日志
    journalctl --vacuum-time=1w
    2)只保留500MB的日志
    journalctl --vacuum-size=500M
    3)直接删除 /var/log/journal/ 目录下的日志文件
    rm -rf /var/log/journal/system@00000000000000000000000000000000-0000000000abaad8-0005a66364beef5c.journal
    1. [root@godba c28d40cbc8e3adcb4e32d9779a77b39e]# journalctl --vacuum-time=1w
    2. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-00000000008bc1e3-0005a3e4ab271bc9.journal (80.0M).
    3. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-00000000008d159f-0005a40371da875c.journal (80.0M).
    4. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-00000000008e68bf-0005a4258ab0a782.journal (80.0M).
    5. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-00000000008fbe58-0005a4421baf997d.journal (80.0M).
    6. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-000000000091140a-0005a45bf6d1c0d9.journal (80.0M).
    7. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-00000000009265ef-0005a479ed5b0247.journal (80.0M).
    8. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-000000000093b7df-0005a4967feb27ea.journal (80.0M).
    9. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-000000000095081c-0005a4b1c4d525fd.journal (80.0M).
    10. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-0000000000965cd6-0005a4c9c136c18f.journal (88.0M).
    11. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-000000000097b6df-0005a4df6d99491f.journal (80.0M).
    12. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-000000000099088d-0005a4f9ca5e73d3.journal (72.0M).
    13. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-00000000009a55b8-0005a519854e60f6.journal (88.0M).
    14. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-00000000009bad27-0005a53391c7af4d.journal (96.0M).
    15. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-00000000009d1222-0005a5443ad05865.journal (88.0M).
    16. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-00000000009e6ab5-0005a55d9014641e.journal (80.0M).
    17. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-00000000009fbcfe-0005a57c9e8ebcbc.journal (80.0M).
    18. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-0000000000a11290-0005a5994b2a772d.journal (80.0M).
    19. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-0000000000a26748-0005a5b3dc5a730e.journal (88.0M).
    20. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-0000000000a3c2c0-0005a5c94cfb4917.journal (80.0M).
    21. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-0000000000a51639-0005a5dfd9cd0516.journal (88.0M).
    22. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-0000000000a673af-0005a5f23d98f494.journal (72.0M).
    23. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-0000000000a7bd1c-0005a6122917487d.journal (80.0M).
    24. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-0000000000a90c0b-0005a62b07e118db.journal (80.0M).
    25. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-0000000000aa6003-0005a64405b0cd7f.journal (72.0M).
    26. Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-0000000000abaad8-0005a66364beef5c.journal (72.0M).
    27. Vacuuming done, freed 1.9G of archived journals on disk.
    28. [root@godba c28d40cbc8e3adcb4e32d9779a77b39e]# df -h
    29. Filesystem      Size  Used Avail Use% Mounted on
    30. devtmpfs        1.9G     0  1.9G   0% /dev
    31. tmpfs           1.9G   24K  1.9G   1% /dev/shm
    32. tmpfs           1.9G  460K  1.9G   1% /run
    33. tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
    34. /dev/vda1        50G  4.3G   43G  10% /
    35. tmpfs           379M     0  379M   0% /run/user/0
    36. [root@godba c28d40cbc8e3adcb4e32d9779a77b39e]#
    复制代码




    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    运维联盟俱乐部 ( 冀ICP备19036648号 )

    GMT+8, 2024-5-4 17:47 , Processed in 0.045990 second(s), 21 queries , Gzip On.

    Powered by Discuz! X3.4

    © 2001-2023 Discuz! Team.

    快速回复 返回顶部 返回列表