{"id":33032,"date":"2020-12-02T15:52:44","date_gmt":"2020-12-02T15:52:44","guid":{"rendered":"http:\/\/ubuntuhandbook.org\/?p=33032"},"modified":"2025-01-19T05:41:10","modified_gmt":"2025-01-19T05:41:10","slug":"clear-systemd-journal-logs-ubuntu","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2020\/12\/clear-systemd-journal-logs-ubuntu\/","title":{"rendered":"Free up Disk Space &#8211; Clear Systemd Journal Logs in Ubuntu 24.04 | 22.04"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10245\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/06\/ubuntu-icon.png\" alt=\"\" width=\"250\" height=\"250\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/06\/ubuntu-icon.png 250w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/06\/ubuntu-icon-150x150.png 150w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/p>\n<p>Going to free up Ubuntu system disk space? Try clearing the systemd journal logs, it may free up a few GB of space.<\/p>\n<p><b>NOTE: This tutorial is tested and works in my case in Ubuntu 24.04, Ubuntu 22.04, and Ubuntu 20.04<\/b><\/p>\n<p>By using the <i>Disk Usage Analyzer<\/i> tool, I found that <b>\/var\/log\/journal<\/b> takes more than 4 GB system space in my Ubuntu 20.04.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-33033\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/12\/big-journal-log.png\" alt=\"\" width=\"600\" height=\"294\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/12\/big-journal-log.png 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/12\/big-journal-log-450x221.png 450w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>Systemd has its own logging system called the journal, and the log files are stored in <b>\/var\/log\/journal<\/b>. As long as I don&#8217;t need the logs for any debugging, <b>it&#8217;s safe to delete these files<\/b>. And following steps will show you how.<\/p>\n<p><b>1.<\/b> First open <b>terminal<\/b> from system app launcher, and you may run command to check out the current disk usage of all journal files:<\/p>\n<pre style=\"border: none;\">journalctl --disk-usage<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-33034\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/12\/journal-diskusage.png\" alt=\"\" width=\"600\" height=\"164\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/12\/journal-diskusage.png 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/12\/journal-diskusage-450x123.png 450w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p><b>2.<\/b> If you decide to clear the logs, run command to rotate the journal files. All currently active journal files will be marked as archived, so that they are never written to in future.<\/p>\n<pre style=\"border: none;\">sudo journalctl --rotate<\/pre>\n<p><b>3. Now clear the journal logs by choosing one of following commands<\/b>:<\/p>\n<ul>\n<li>Delete journal logs older than X days:\n<pre style=\"border: none;\">sudo journalctl --vacuum-time=2days<\/pre>\n<\/li>\n<li>Delete log files until the disk space taken falls below the specified size:\n<pre style=\"border: none;\">sudo journalctl --vacuum-size=100M<\/pre>\n<\/li>\n<li>Delete old logs and limit file number to X:\n<pre style=\"border: none;\">sudo journalctl --vacuum-files=5<\/pre>\n<\/li>\n<\/ul>\n<p><b>4.<\/b> You can also edit the configuration file to limit the journal log disk usage (<b>100 MB<\/b> for example).<\/p>\n<p>Run command in terminal to edit the file via Gedit text editor (For 24.04+, replace <code>gedit<\/code> with <code>gnome-text-editor<\/code> or use <code>nano<\/code> that works in most desktops):<\/p>\n<pre style=\"border: None;\">sudo -H gedit \/etc\/systemd\/journald.conf<\/pre>\n<p>When the file opens, un-comment (remove # at the beginning) the line <b>#SystemMaxUse=<\/b> and change it to <b>SystemMaxUse=100M<\/b>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-33036\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/12\/limit-logusage.png\" alt=\"\" width=\"600\" height=\"246\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/12\/limit-logusage.png 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2020\/12\/limit-logusage-450x185.png 450w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>Finally, save the file (for nano, press Ctrl+S then Ctrl+X) and reload systemd daemon via command:<\/p>\n<pre style=\"border: None;\">systemctl daemon-reload<\/pre>\n<p>That&#8217;s all, Enjoy!<\/p>","protected":false},"excerpt":{"rendered":"<p>Going to free up Ubuntu system disk space? Try clearing the systemd journal logs, it may free up a few GB of space. NOTE: This tutorial is tested and works in my case in Ubuntu 24.04, Ubuntu 22.04, and Ubuntu 20.04 By using the Disk Usage Analyzer tool, I found that \/var\/log\/journal takes more than [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[2005],"class_list":["post-33032","post","type-post","status-publish","format-standard","hentry","category-howtos","tag-systemd"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/33032","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=33032"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/33032\/revisions"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=33032"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=33032"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=33032"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}