Deleting/Clearing systemd journal files, like btmp, and other log files

Check and clean log files – /var/log/

To determine the total used space of /var/log/ and /var/log/journal/*/:

Bash
root@server:~# du -hs /var/log/
1.6G    /var/log/
root@server:~# du -hs /var/log/journal/
1.4G    /var/log/journal/
root@server:~#


Display the largest log file of the last 3 months /var/log/journal/*/:

Bash
root@server:~# ls -lath /var/log/journal/*/ | tail -n 3
-rw-r-x---+ 1 root systemd-journal   48M Mar 23 04:05 system@123456xyz.journal


1. Display exact size of the file var/log/btmp in KB.

2. Clear the file /var/log/btmp.

3. Display current size of the emptied file var/log/btmp in KB.

Bash
root@server:~# du --apparent-size /var/log/btmp
15      /var/log/btmp
root@server:~# > /var/log/btmp
root@server:~# du --apparent-size /var/log/btmp
0       /var/log/btmp


Deleting all systemd journal files older than 20 days

Bash
root@server:~# journalctl --vacuum-time=20d
Journal file /var/log/journal/12345/user-1000.journal is truncated, ignoring file.
Deleted archived journal /var/log/journal/12345/system@12345-0123-12345.journal (48.0M).
Deleted archived journal /var/log/journal/12345/system@12345-0123-12345.journal (104.0M).
Deleted archived journal /var/log/journal/12345/user-10008@12345-0123-12345.journal(8.0M).
Vacuuming done, freed 2.7M of archived journals from /var/log/journal/12345.


Deleting all systemd journal files that exceed a disk size of x.

Bash
root@server:~# journalctl --vacuum-size=1G
Deleted archived journal /var/log/journal/12345/system@12345-0123-12345.journal (104.0M).
Vacuuming done, freed 3.9G of archived journals from /var/log/journal/12345.
root@server:~#

More Articles

Redis 5.0.5 Installation / Update / Upgrade
Cron job – Generating weekly new DH PARAM files

Navigation

  1. Community
  2. Forum
  3. Shop
  4. My Account
  5. World
    1. WOLTLAB SPANISH
    2. WOLTLAB PORTUGUESE
    3. WOLTLAB POLISH
    4. Adding Language
    5. Create Article
  6. Chat
  7. EN
  1. Contact
  2. Legal Notice
  3. Privacy Policy
  4. Terms
  5. Disclaimer
  6. Copyrights
  7. Cookies
  8. DONATE

Current Location

This site uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.