How to clear systemd journal logs by time
How to clear systemd journal logs by time?
Run the journalctl command and define a vacuum time to clear out the journal logs.
journalctl --vacuum-time=TIMEThe journalctl command can be used to remove older journal logs by using the --vacuum-time option, followed by a time. This time defines the maximum age of entries.
Usage
Before clearing out any journal logs, it may be useful to see the current disk usage first. Use the --disk-usage option to show
# journalctl --disk-usage
Archived and active journals take up 256.0M in the file system.
To remove all journal logs older than 30 days, define ‘30d’ as its period.
# journalctl --vacuum-time=30d
Deleted archived journal /var/log/journal/d8da4544b42732906a930deaba49a506/user-1000@aeb5e2f412954ecfaa870c245338cb93-0000000000022eb1-000618f16cbeab92.journal (8.0M).
Deleted archived journal /var/log/journal/d8da4544b42732906a930deaba49a506/system@ca889eb2eae24e41b37a50d33bad131c-0000000000026d71-00061acf10c2969d.journal (8.0M).
Deleted archived journal /var/log/journal/d8da4544b42732906a930deaba49a506/user-1000@aeb5e2f412954ecfaa870c245338cb93-00000000000271d2-00061aeda8cf5fdd.journal (8.0M).
Deleted archived journal /var/log/journal/d8da4544b42732906a930deaba49a506/system@ca889eb2eae24e41b37a50d33bad131c-00000000000271ea-00061aedb700b831.journal (24.0M).
Deleted archived journal /var/log/journal/d8da4544b42732906a930deaba49a506/user-1000@aeb5e2f412954ecfaa870c245338cb93-00000000000271eb-00061aedb7013c8a.journal (8.0M).
Deleted archived journal /var/log/journal/d8da4544b42732906a930deaba49a506/system@ca889eb2eae24e41b37a50d33bad131c-000000000002bfcd-00061d5203640666.journal (16.0M).
Deleted archived journal /var/log/journal/d8da4544b42732906a930deaba49a506/user-1000@aeb5e2f412954ecfaa870c245338cb93-000000000002d64e-00061e085359feff.journal (8.0M).
Deleted archived journal /var/log/journal/d8da4544b42732906a930deaba49a506/system@ca889eb2eae24e41b37a50d33bad131c-000000000002f181-00061eaaa9badf82.journal (16.0M).
Deleted archived journal /var/log/journal/d8da4544b42732906a930deaba49a506/system@ca889eb2eae24e41b37a50d33bad131c-000000000003237e-0006203b3f8d0893.journal (16.0M).
Deleted archived journal /var/log/journal/d8da4544b42732906a930deaba49a506/user-1000@aeb5e2f412954ecfaa870c245338cb93-00000000000341a1-00062132520d58aa.journal (8.0M).
Deleted archived journal /var/log/journal/d8da4544b42732906a930deaba49a506/system@ca889eb2eae24e41b37a50d33bad131c-00000000000354b9-000621d042fce1c1.journal (16.0M).
Deleted archived journal /var/log/journal/d8da4544b42732906a930deaba49a506/user-1000@aeb5e2f412954ecfaa870c245338cb93-0000000000035a59-000621ff787d8caf.journal (8.0M).
Deleted archived journal /var/log/journal/d8da4544b42732906a930deaba49a506/system@ca889eb2eae24e41b37a50d33bad131c-0000000000038580-0006236a1be25d21.journal (16.0M).
Deleted archived journal /var/log/journal/d8da4544b42732906a930deaba49a506/user-1000@aeb5e2f412954ecfaa870c245338cb93-00000000000395fc-000623f52ec71ab7.journal (8.0M).
Vacuuming done, freed 168.0M of archived journals from /var/log/journal/d8da4544b42732906a930deaba49a506.
Vacuuming done, freed 0B of archived journals from /var/log/journal.
Vacuuming done, freed 0B of archived journals from /run/log/journal.