{"id":1646,"date":"2024-11-03T11:13:58","date_gmt":"2024-11-03T03:13:58","guid":{"rendered":"https:\/\/www.computersolutions.cn\/blog\/?p=1646"},"modified":"2024-11-03T11:22:03","modified_gmt":"2024-11-03T03:22:03","slug":"systemd-logs-journalctl-cleanup","status":"publish","type":"post","link":"https:\/\/www.computersolutions.cn\/blog\/2024\/11\/systemd-logs-journalctl-cleanup\/","title":{"rendered":"Systemd logs &#8211; journalctl cleanup"},"content":{"rendered":"<p>Journalctl keeps logs on the servers for systemd.<br \/>\nThe default settings can lead to too much disk space use.  Logs are good to have, but the default settings are unlimited, and if you do not watch out they can get up to gigabytes in size.  A more reasonable default is 100M, as this will still allow you to debug any non-running systemd scripts and not take up too much valuable disk space.<\/p>\n\n<p>To reduce journalctl disk usage, we can clean up the un-needed logs, and optionally reduce the disk space needed to keep logs.<\/p>\n\n<p>To Show disk usage:<\/p>\n\n<pre class=\"wp-block-code\"><code>journalctl --disk-usage<\/code><\/pre>\n\n\n<p>To clean up disk usage (to 100M in size):<\/p>\n\n<pre class=\"wp-block-code\"><code>journalctl --vacuum-size=100M<\/code><\/pre>\n\n\n\n<p>To make this the default for future, we can edit the systemd journald settings and set the logs to a more reasonable size.:<\/p>\n\n<pre class=\"wp-block-code\"><code>\npico \/etc\/systemd\/journald.conf\n\n\/\/Uncomment the SystemMaxUse line and set to 100M\nSystemMaxUse=100M\n\n\/\/Save and exit CTRL O, CTRL X, Enter to save\n\n\/\/Finally restart systemd\nsystemctl restart systemd-journald\n<\/code><\/pre>\n\n<p><b>Note:<\/b> Logs can be seen by checking one of the running services. These usually sit in \/etc\/systemd\/system or \/etc\/systemd\/user.<br \/>e.g. to check php 8.3 fpm service logs<\/p>\n\n<pre class=\"wp-block-code\"><code>journalctl -xeu php8.3-fpm.service\n<\/code><\/pre>\n\n\n\n","protected":false},"excerpt":{"rendered":"<p>Journalctl keeps logs on the servers for systemd. The default settings can lead to too much disk space use. Logs are good to have, but the default settings are unlimited, and if you do not watch out they can get up to gigabytes in size. A more reasonable default is 100M, as this will still [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[549,548,550,547],"class_list":["post-1646","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-disk-usage","tag-journalctl","tag-linux","tag-systemd"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/posts\/1646","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/comments?post=1646"}],"version-history":[{"count":5,"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/posts\/1646\/revisions"}],"predecessor-version":[{"id":1653,"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/posts\/1646\/revisions\/1653"}],"wp:attachment":[{"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/media?parent=1646"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/categories?post=1646"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.computersolutions.cn\/blog\/wp-json\/wp\/v2\/tags?post=1646"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}