admin 发表于 2020-6-2 01:08:10

清空/var/log/journal日志

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
# journalctl --vacuum-time=1w
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-00000000008bc1e3-0005a3e4ab271bc9.journal (80.0M).
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-00000000008d159f-0005a40371da875c.journal (80.0M).
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-00000000008e68bf-0005a4258ab0a782.journal (80.0M).
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-00000000008fbe58-0005a4421baf997d.journal (80.0M).
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-000000000091140a-0005a45bf6d1c0d9.journal (80.0M).
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-00000000009265ef-0005a479ed5b0247.journal (80.0M).
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-000000000093b7df-0005a4967feb27ea.journal (80.0M).
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-000000000095081c-0005a4b1c4d525fd.journal (80.0M).
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-0000000000965cd6-0005a4c9c136c18f.journal (88.0M).
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-000000000097b6df-0005a4df6d99491f.journal (80.0M).
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-000000000099088d-0005a4f9ca5e73d3.journal (72.0M).
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-00000000009a55b8-0005a519854e60f6.journal (88.0M).
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-00000000009bad27-0005a53391c7af4d.journal (96.0M).
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-00000000009d1222-0005a5443ad05865.journal (88.0M).
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-00000000009e6ab5-0005a55d9014641e.journal (80.0M).
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-00000000009fbcfe-0005a57c9e8ebcbc.journal (80.0M).
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-0000000000a11290-0005a5994b2a772d.journal (80.0M).
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-0000000000a26748-0005a5b3dc5a730e.journal (88.0M).
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-0000000000a3c2c0-0005a5c94cfb4917.journal (80.0M).
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-0000000000a51639-0005a5dfd9cd0516.journal (88.0M).
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-0000000000a673af-0005a5f23d98f494.journal (72.0M).
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-0000000000a7bd1c-0005a6122917487d.journal (80.0M).
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-0000000000a90c0b-0005a62b07e118db.journal (80.0M).
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-0000000000aa6003-0005a64405b0cd7f.journal (72.0M).
Deleted archived journal /var/log/journal/c28d40cbc8e3adcb4e32d9779a77b39e/system@00000000000000000000000000000000-0000000000abaad8-0005a66364beef5c.journal (72.0M).
Vacuuming done, freed 1.9G of archived journals on disk.
# df -h
Filesystem      SizeUsed Avail Use% Mounted on
devtmpfs      1.9G   01.9G   0% /dev
tmpfs         1.9G   24K1.9G   1% /dev/shm
tmpfs         1.9G460K1.9G   1% /run
tmpfs         1.9G   01.9G   0% /sys/fs/cgroup
/dev/vda1      50G4.3G   43G10% /
tmpfs         379M   0379M   0% /run/user/0
#



页: [1]
查看完整版本: 清空/var/log/journal日志