How to clear journalctl












169















I couldn't find in google any safe way to clear systemd journal. Do anyone know any safe and reliable way to do so?



Let's say I was experimenting with something and my logs got cluttered with various error messages. Moreover I'm displaying my journal on my desktop by using Conky. I really don't want to see those errors as they remind me an awful day I was fixing this stuff, I want to feel like a fresh man after this horror. I think everyone will agree that this is a valid reason to clear the logs :P .










share|improve this question





























    169















    I couldn't find in google any safe way to clear systemd journal. Do anyone know any safe and reliable way to do so?



    Let's say I was experimenting with something and my logs got cluttered with various error messages. Moreover I'm displaying my journal on my desktop by using Conky. I really don't want to see those errors as they remind me an awful day I was fixing this stuff, I want to feel like a fresh man after this horror. I think everyone will agree that this is a valid reason to clear the logs :P .










    share|improve this question



























      169












      169








      169


      56






      I couldn't find in google any safe way to clear systemd journal. Do anyone know any safe and reliable way to do so?



      Let's say I was experimenting with something and my logs got cluttered with various error messages. Moreover I'm displaying my journal on my desktop by using Conky. I really don't want to see those errors as they remind me an awful day I was fixing this stuff, I want to feel like a fresh man after this horror. I think everyone will agree that this is a valid reason to clear the logs :P .










      share|improve this question
















      I couldn't find in google any safe way to clear systemd journal. Do anyone know any safe and reliable way to do so?



      Let's say I was experimenting with something and my logs got cluttered with various error messages. Moreover I'm displaying my journal on my desktop by using Conky. I really don't want to see those errors as they remind me an awful day I was fixing this stuff, I want to feel like a fresh man after this horror. I think everyone will agree that this is a valid reason to clear the logs :P .







      systemd systemd-journald






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 23 '17 at 20:13









      sourcejedi

      24.2k439106




      24.2k439106










      asked Jun 27 '14 at 11:43









      Łukasz ZarodaŁukasz Zaroda

      1,1102913




      1,1102913






















          8 Answers
          8






          active

          oldest

          votes


















          223














          The self maintenance method is to vacuum the logs by size or time.



          Retain only the past two days:



          journalctl --vacuum-time=2d


          Retain only the past 500 MB:



          journalctl --vacuum-size=500M


          man journalctl for more information.






          share|improve this answer



















          • 10





            Nice command, but didn't work for me on openSUSE 13.2 (the current stable release). It's known that Arch is usually at the cutting edge when it comes to kernel and userland programs, so I speculated that vacuum options might have been recently added to systemd and simply haven't precipitated down into my distro. Confirmed the fact here in Lennart's announcement on Dec 10 2014 techupdates.com/go/1002774 that this command was added in systemd v218. Just adding this comment incase any one else like me who is not on Arch has a similar issue. Upvoted anyway.

            – Joshua Huber
            Apr 23 '15 at 0:33













          • I just used 'journalctl --vacuum-time=1d' to fix a situation where new log messages weren't showing with 'journalctl -f'. Apparently my system time had temporarily jumped about a day forward for a while, then recovered, and journalctl was using the log event timestamps from that future time as the journal tail.

            – user5071535
            Nov 16 '15 at 18:23






          • 7





            Didn't work in version "systemd 229" on Ubuntu 16.04. journalctl --vacuum-size=1K then journalctl still shows way more than 1K. It shows all the messages since the last boot.

            – Dan Dascalescu
            Sep 10 '16 at 4:23






          • 13





            It seems that this only clears archived logs, not active ones. I tried running journalctl --flush --rotate before journalctl --vacuum-time=1s and it removed more stuff, although still not everything.

            – user60039
            Feb 7 '17 at 19:42








          • 1





            The documentation doesn't seem so clear to me. Does it always stay set to 2d (in your example)? Or is 2d from the time you run the command? Maybe I'm not understanding how this works exactly.

            – jersey bean
            Aug 3 '17 at 1:49



















          60














          You don't typically clear the journal yourself. That is managed by systemd itself and old logs are rotated out as new data comes in. The correct thing to do would be to schedule journald to only keep as much data as you are interested in. The most usual thing to adjust is the total disk space it is allowed to take up. Once it crosses this boundry it will start pitching old entries to stay near this value.



          You can set this in /etc/systemd/journald.conf like so:



          SystemMaxUse=100M





          share|improve this answer





















          • 10





            Ok, but there are also untypical situations. I know that most of them is just aesthetics as a reason, but aesthetics is a valid reason for human being ;) .

            – Łukasz Zaroda
            Jun 27 '14 at 12:08






          • 2





            @ŁukaszZaroda In that case you are going to have to define "safe". Normally "I want to blow away something that a daemon is configured to keep" is incompatible with "safe". If you want to force it just shut down the service and zero out the log files. If you want it to work normally you should define the parameters in your question better. What do you mean by "safe"?

            – Caleb
            Jun 27 '14 at 12:17











          • By safe, I mean that after clearing it will work as usual, just starting from the new place.

            – Łukasz Zaroda
            Jun 27 '14 at 12:19






          • 5





            It may be not typical situation but sometimes it is necessary to delete old logs due to some systemd's bugs, e.g. bbs.archlinux.org/viewtopic.php?pid=1173031#p1173031

            – diffycat
            Jun 27 '14 at 15:57






          • 1





            To clean logs after a period of time rather than when they reach a certain size, you can set the parameter MaxRetentionSec instead of SystemMaxUse. See man journald.conf for more details.

            – joelostblom
            Mar 29 '18 at 13:08



















          16














          Michael's answer is missing one thing: vacuuming only removes archived journal files, not active ones. To get rid of everything, you need to rotate the files first so that recent entries are moved to inactive files.



          So, the complete answer to remove all entries seems to be



          journalctl --rotate
          journalctl --vacuum-time=1s


          (Note that you cannot combine this into one journalctl command.)



          By the way, some distributions have journald configured so that it writes logs to disk (/var/log/journal) while others keep logs in memory (/run/log/journal). I expect that in some cases it may be necessary to use journalctl --flush first to get everything removed.



          If you don't have --rotate in your version, you can use the --since argument to filter entries:



          --since "2019-01-30 14:00:00"
          --since today





          share|improve this answer


























          • journalctl: unrecognized option '--rotate'

            – stiv
            Oct 7 '18 at 12:22






          • 1





            while I get what the other answers are approaching (long term strategy) - the question is simple: how do you clear logs now (maybe you're not interested in the long term for your current task). This answers that question without making other assumptions and adds other great value to understanding journalctl. This should be the answer.

            – Marc
            Oct 20 '18 at 15:39



















          14














          On Arch linux, the closest I got was:




          • Edit /etc/systemd/journald.conf to set SystemMaxUse=1M

          • Restarting journal: sudo systemctl restart systemd-journald

          • Resetting SystemMaxUse=200M

          • Re-Restarting the journal


          On my system, each journal file is 8MB, and the above cleared all but 3, bringing the total size to ~25MB.



          My use-case was disabling CoW for BTRFS (just for the journal directory and subdirectories): sudo chattr +C /var/log/journal/*. The problem is, the attribute is only set on newly-created files, thus the desire to flush the journal.






          share|improve this answer



















          • 4





            Your use-case was actually not needed. The point of disabling CoW on the journal is that it is frequently written to. That is not the case for the old rotated journal files, they just sit there.

            – Hjulle
            Mar 31 '15 at 10:03






          • 1





            I've set SystemMaxUse=1K, restarted systemd-journald, but journalctl still shows entries I want gone. How is this progress from flat text files?

            – Dan Dascalescu
            Sep 10 '16 at 4:18



















          10














          A very brute force method to clean the entire log:



          $ sudo journalctl --vacuum-time=1seconds


          You can also use --vacuum-size as Michael mentoined.






          share|improve this answer



















          • 5





            Didn't work. Entries for 15 minutes ago still show up, even after running systemctl restart systemd-journald.

            – Dan Dascalescu
            Sep 10 '16 at 4:15






          • 1





            Same here. This didn't work for me either. I'm running CentOS7.

            – jersey bean
            Aug 3 '17 at 1:55



















          9














          Since --vacuum-time and --vacuum-size didn't do a thing for me I did the following:



          $ sudo find /var/log/journal -name "*.journal" | xargs sudo rm 
          $ sudo systemctl restart systemd-journald


          It's not right, but it worked.






          share|improve this answer


























          • On Debian Jessie, the path is /run/log.

            – Synchro
            Feb 12 '18 at 18:23











          • only this helped me !

            – T.Todua
            Nov 27 '18 at 10:49





















          0














          journal-ctl -b-0 will show only from the most recent boot. You can also use -1, -2 etc. Your horrendous day is still there but you won't have to see it, unless you need to.






          share|improve this answer































            0














            Both --rotate and --vacuum-time=1s didn't work for me on CentOS. I was able to clear it like this:



            sudo rm -rf /run/log/journal/*





            share|improve this answer























              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "106"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f139513%2fhow-to-clear-journalctl%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              8 Answers
              8






              active

              oldest

              votes








              8 Answers
              8






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              223














              The self maintenance method is to vacuum the logs by size or time.



              Retain only the past two days:



              journalctl --vacuum-time=2d


              Retain only the past 500 MB:



              journalctl --vacuum-size=500M


              man journalctl for more information.






              share|improve this answer



















              • 10





                Nice command, but didn't work for me on openSUSE 13.2 (the current stable release). It's known that Arch is usually at the cutting edge when it comes to kernel and userland programs, so I speculated that vacuum options might have been recently added to systemd and simply haven't precipitated down into my distro. Confirmed the fact here in Lennart's announcement on Dec 10 2014 techupdates.com/go/1002774 that this command was added in systemd v218. Just adding this comment incase any one else like me who is not on Arch has a similar issue. Upvoted anyway.

                – Joshua Huber
                Apr 23 '15 at 0:33













              • I just used 'journalctl --vacuum-time=1d' to fix a situation where new log messages weren't showing with 'journalctl -f'. Apparently my system time had temporarily jumped about a day forward for a while, then recovered, and journalctl was using the log event timestamps from that future time as the journal tail.

                – user5071535
                Nov 16 '15 at 18:23






              • 7





                Didn't work in version "systemd 229" on Ubuntu 16.04. journalctl --vacuum-size=1K then journalctl still shows way more than 1K. It shows all the messages since the last boot.

                – Dan Dascalescu
                Sep 10 '16 at 4:23






              • 13





                It seems that this only clears archived logs, not active ones. I tried running journalctl --flush --rotate before journalctl --vacuum-time=1s and it removed more stuff, although still not everything.

                – user60039
                Feb 7 '17 at 19:42








              • 1





                The documentation doesn't seem so clear to me. Does it always stay set to 2d (in your example)? Or is 2d from the time you run the command? Maybe I'm not understanding how this works exactly.

                – jersey bean
                Aug 3 '17 at 1:49
















              223














              The self maintenance method is to vacuum the logs by size or time.



              Retain only the past two days:



              journalctl --vacuum-time=2d


              Retain only the past 500 MB:



              journalctl --vacuum-size=500M


              man journalctl for more information.






              share|improve this answer



















              • 10





                Nice command, but didn't work for me on openSUSE 13.2 (the current stable release). It's known that Arch is usually at the cutting edge when it comes to kernel and userland programs, so I speculated that vacuum options might have been recently added to systemd and simply haven't precipitated down into my distro. Confirmed the fact here in Lennart's announcement on Dec 10 2014 techupdates.com/go/1002774 that this command was added in systemd v218. Just adding this comment incase any one else like me who is not on Arch has a similar issue. Upvoted anyway.

                – Joshua Huber
                Apr 23 '15 at 0:33













              • I just used 'journalctl --vacuum-time=1d' to fix a situation where new log messages weren't showing with 'journalctl -f'. Apparently my system time had temporarily jumped about a day forward for a while, then recovered, and journalctl was using the log event timestamps from that future time as the journal tail.

                – user5071535
                Nov 16 '15 at 18:23






              • 7





                Didn't work in version "systemd 229" on Ubuntu 16.04. journalctl --vacuum-size=1K then journalctl still shows way more than 1K. It shows all the messages since the last boot.

                – Dan Dascalescu
                Sep 10 '16 at 4:23






              • 13





                It seems that this only clears archived logs, not active ones. I tried running journalctl --flush --rotate before journalctl --vacuum-time=1s and it removed more stuff, although still not everything.

                – user60039
                Feb 7 '17 at 19:42








              • 1





                The documentation doesn't seem so clear to me. Does it always stay set to 2d (in your example)? Or is 2d from the time you run the command? Maybe I'm not understanding how this works exactly.

                – jersey bean
                Aug 3 '17 at 1:49














              223












              223








              223







              The self maintenance method is to vacuum the logs by size or time.



              Retain only the past two days:



              journalctl --vacuum-time=2d


              Retain only the past 500 MB:



              journalctl --vacuum-size=500M


              man journalctl for more information.






              share|improve this answer













              The self maintenance method is to vacuum the logs by size or time.



              Retain only the past two days:



              journalctl --vacuum-time=2d


              Retain only the past 500 MB:



              journalctl --vacuum-size=500M


              man journalctl for more information.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Apr 2 '15 at 16:43









              MichaelMichael

              2,254162




              2,254162








              • 10





                Nice command, but didn't work for me on openSUSE 13.2 (the current stable release). It's known that Arch is usually at the cutting edge when it comes to kernel and userland programs, so I speculated that vacuum options might have been recently added to systemd and simply haven't precipitated down into my distro. Confirmed the fact here in Lennart's announcement on Dec 10 2014 techupdates.com/go/1002774 that this command was added in systemd v218. Just adding this comment incase any one else like me who is not on Arch has a similar issue. Upvoted anyway.

                – Joshua Huber
                Apr 23 '15 at 0:33













              • I just used 'journalctl --vacuum-time=1d' to fix a situation where new log messages weren't showing with 'journalctl -f'. Apparently my system time had temporarily jumped about a day forward for a while, then recovered, and journalctl was using the log event timestamps from that future time as the journal tail.

                – user5071535
                Nov 16 '15 at 18:23






              • 7





                Didn't work in version "systemd 229" on Ubuntu 16.04. journalctl --vacuum-size=1K then journalctl still shows way more than 1K. It shows all the messages since the last boot.

                – Dan Dascalescu
                Sep 10 '16 at 4:23






              • 13





                It seems that this only clears archived logs, not active ones. I tried running journalctl --flush --rotate before journalctl --vacuum-time=1s and it removed more stuff, although still not everything.

                – user60039
                Feb 7 '17 at 19:42








              • 1





                The documentation doesn't seem so clear to me. Does it always stay set to 2d (in your example)? Or is 2d from the time you run the command? Maybe I'm not understanding how this works exactly.

                – jersey bean
                Aug 3 '17 at 1:49














              • 10





                Nice command, but didn't work for me on openSUSE 13.2 (the current stable release). It's known that Arch is usually at the cutting edge when it comes to kernel and userland programs, so I speculated that vacuum options might have been recently added to systemd and simply haven't precipitated down into my distro. Confirmed the fact here in Lennart's announcement on Dec 10 2014 techupdates.com/go/1002774 that this command was added in systemd v218. Just adding this comment incase any one else like me who is not on Arch has a similar issue. Upvoted anyway.

                – Joshua Huber
                Apr 23 '15 at 0:33













              • I just used 'journalctl --vacuum-time=1d' to fix a situation where new log messages weren't showing with 'journalctl -f'. Apparently my system time had temporarily jumped about a day forward for a while, then recovered, and journalctl was using the log event timestamps from that future time as the journal tail.

                – user5071535
                Nov 16 '15 at 18:23






              • 7





                Didn't work in version "systemd 229" on Ubuntu 16.04. journalctl --vacuum-size=1K then journalctl still shows way more than 1K. It shows all the messages since the last boot.

                – Dan Dascalescu
                Sep 10 '16 at 4:23






              • 13





                It seems that this only clears archived logs, not active ones. I tried running journalctl --flush --rotate before journalctl --vacuum-time=1s and it removed more stuff, although still not everything.

                – user60039
                Feb 7 '17 at 19:42








              • 1





                The documentation doesn't seem so clear to me. Does it always stay set to 2d (in your example)? Or is 2d from the time you run the command? Maybe I'm not understanding how this works exactly.

                – jersey bean
                Aug 3 '17 at 1:49








              10




              10





              Nice command, but didn't work for me on openSUSE 13.2 (the current stable release). It's known that Arch is usually at the cutting edge when it comes to kernel and userland programs, so I speculated that vacuum options might have been recently added to systemd and simply haven't precipitated down into my distro. Confirmed the fact here in Lennart's announcement on Dec 10 2014 techupdates.com/go/1002774 that this command was added in systemd v218. Just adding this comment incase any one else like me who is not on Arch has a similar issue. Upvoted anyway.

              – Joshua Huber
              Apr 23 '15 at 0:33







              Nice command, but didn't work for me on openSUSE 13.2 (the current stable release). It's known that Arch is usually at the cutting edge when it comes to kernel and userland programs, so I speculated that vacuum options might have been recently added to systemd and simply haven't precipitated down into my distro. Confirmed the fact here in Lennart's announcement on Dec 10 2014 techupdates.com/go/1002774 that this command was added in systemd v218. Just adding this comment incase any one else like me who is not on Arch has a similar issue. Upvoted anyway.

              – Joshua Huber
              Apr 23 '15 at 0:33















              I just used 'journalctl --vacuum-time=1d' to fix a situation where new log messages weren't showing with 'journalctl -f'. Apparently my system time had temporarily jumped about a day forward for a while, then recovered, and journalctl was using the log event timestamps from that future time as the journal tail.

              – user5071535
              Nov 16 '15 at 18:23





              I just used 'journalctl --vacuum-time=1d' to fix a situation where new log messages weren't showing with 'journalctl -f'. Apparently my system time had temporarily jumped about a day forward for a while, then recovered, and journalctl was using the log event timestamps from that future time as the journal tail.

              – user5071535
              Nov 16 '15 at 18:23




              7




              7





              Didn't work in version "systemd 229" on Ubuntu 16.04. journalctl --vacuum-size=1K then journalctl still shows way more than 1K. It shows all the messages since the last boot.

              – Dan Dascalescu
              Sep 10 '16 at 4:23





              Didn't work in version "systemd 229" on Ubuntu 16.04. journalctl --vacuum-size=1K then journalctl still shows way more than 1K. It shows all the messages since the last boot.

              – Dan Dascalescu
              Sep 10 '16 at 4:23




              13




              13





              It seems that this only clears archived logs, not active ones. I tried running journalctl --flush --rotate before journalctl --vacuum-time=1s and it removed more stuff, although still not everything.

              – user60039
              Feb 7 '17 at 19:42







              It seems that this only clears archived logs, not active ones. I tried running journalctl --flush --rotate before journalctl --vacuum-time=1s and it removed more stuff, although still not everything.

              – user60039
              Feb 7 '17 at 19:42






              1




              1





              The documentation doesn't seem so clear to me. Does it always stay set to 2d (in your example)? Or is 2d from the time you run the command? Maybe I'm not understanding how this works exactly.

              – jersey bean
              Aug 3 '17 at 1:49





              The documentation doesn't seem so clear to me. Does it always stay set to 2d (in your example)? Or is 2d from the time you run the command? Maybe I'm not understanding how this works exactly.

              – jersey bean
              Aug 3 '17 at 1:49













              60














              You don't typically clear the journal yourself. That is managed by systemd itself and old logs are rotated out as new data comes in. The correct thing to do would be to schedule journald to only keep as much data as you are interested in. The most usual thing to adjust is the total disk space it is allowed to take up. Once it crosses this boundry it will start pitching old entries to stay near this value.



              You can set this in /etc/systemd/journald.conf like so:



              SystemMaxUse=100M





              share|improve this answer





















              • 10





                Ok, but there are also untypical situations. I know that most of them is just aesthetics as a reason, but aesthetics is a valid reason for human being ;) .

                – Łukasz Zaroda
                Jun 27 '14 at 12:08






              • 2





                @ŁukaszZaroda In that case you are going to have to define "safe". Normally "I want to blow away something that a daemon is configured to keep" is incompatible with "safe". If you want to force it just shut down the service and zero out the log files. If you want it to work normally you should define the parameters in your question better. What do you mean by "safe"?

                – Caleb
                Jun 27 '14 at 12:17











              • By safe, I mean that after clearing it will work as usual, just starting from the new place.

                – Łukasz Zaroda
                Jun 27 '14 at 12:19






              • 5





                It may be not typical situation but sometimes it is necessary to delete old logs due to some systemd's bugs, e.g. bbs.archlinux.org/viewtopic.php?pid=1173031#p1173031

                – diffycat
                Jun 27 '14 at 15:57






              • 1





                To clean logs after a period of time rather than when they reach a certain size, you can set the parameter MaxRetentionSec instead of SystemMaxUse. See man journald.conf for more details.

                – joelostblom
                Mar 29 '18 at 13:08
















              60














              You don't typically clear the journal yourself. That is managed by systemd itself and old logs are rotated out as new data comes in. The correct thing to do would be to schedule journald to only keep as much data as you are interested in. The most usual thing to adjust is the total disk space it is allowed to take up. Once it crosses this boundry it will start pitching old entries to stay near this value.



              You can set this in /etc/systemd/journald.conf like so:



              SystemMaxUse=100M





              share|improve this answer





















              • 10





                Ok, but there are also untypical situations. I know that most of them is just aesthetics as a reason, but aesthetics is a valid reason for human being ;) .

                – Łukasz Zaroda
                Jun 27 '14 at 12:08






              • 2





                @ŁukaszZaroda In that case you are going to have to define "safe". Normally "I want to blow away something that a daemon is configured to keep" is incompatible with "safe". If you want to force it just shut down the service and zero out the log files. If you want it to work normally you should define the parameters in your question better. What do you mean by "safe"?

                – Caleb
                Jun 27 '14 at 12:17











              • By safe, I mean that after clearing it will work as usual, just starting from the new place.

                – Łukasz Zaroda
                Jun 27 '14 at 12:19






              • 5





                It may be not typical situation but sometimes it is necessary to delete old logs due to some systemd's bugs, e.g. bbs.archlinux.org/viewtopic.php?pid=1173031#p1173031

                – diffycat
                Jun 27 '14 at 15:57






              • 1





                To clean logs after a period of time rather than when they reach a certain size, you can set the parameter MaxRetentionSec instead of SystemMaxUse. See man journald.conf for more details.

                – joelostblom
                Mar 29 '18 at 13:08














              60












              60








              60







              You don't typically clear the journal yourself. That is managed by systemd itself and old logs are rotated out as new data comes in. The correct thing to do would be to schedule journald to only keep as much data as you are interested in. The most usual thing to adjust is the total disk space it is allowed to take up. Once it crosses this boundry it will start pitching old entries to stay near this value.



              You can set this in /etc/systemd/journald.conf like so:



              SystemMaxUse=100M





              share|improve this answer















              You don't typically clear the journal yourself. That is managed by systemd itself and old logs are rotated out as new data comes in. The correct thing to do would be to schedule journald to only keep as much data as you are interested in. The most usual thing to adjust is the total disk space it is allowed to take up. Once it crosses this boundry it will start pitching old entries to stay near this value.



              You can set this in /etc/systemd/journald.conf like so:



              SystemMaxUse=100M






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Jun 27 '14 at 11:59

























              answered Jun 27 '14 at 11:52









              CalebCaleb

              50.9k9149192




              50.9k9149192








              • 10





                Ok, but there are also untypical situations. I know that most of them is just aesthetics as a reason, but aesthetics is a valid reason for human being ;) .

                – Łukasz Zaroda
                Jun 27 '14 at 12:08






              • 2





                @ŁukaszZaroda In that case you are going to have to define "safe". Normally "I want to blow away something that a daemon is configured to keep" is incompatible with "safe". If you want to force it just shut down the service and zero out the log files. If you want it to work normally you should define the parameters in your question better. What do you mean by "safe"?

                – Caleb
                Jun 27 '14 at 12:17











              • By safe, I mean that after clearing it will work as usual, just starting from the new place.

                – Łukasz Zaroda
                Jun 27 '14 at 12:19






              • 5





                It may be not typical situation but sometimes it is necessary to delete old logs due to some systemd's bugs, e.g. bbs.archlinux.org/viewtopic.php?pid=1173031#p1173031

                – diffycat
                Jun 27 '14 at 15:57






              • 1





                To clean logs after a period of time rather than when they reach a certain size, you can set the parameter MaxRetentionSec instead of SystemMaxUse. See man journald.conf for more details.

                – joelostblom
                Mar 29 '18 at 13:08














              • 10





                Ok, but there are also untypical situations. I know that most of them is just aesthetics as a reason, but aesthetics is a valid reason for human being ;) .

                – Łukasz Zaroda
                Jun 27 '14 at 12:08






              • 2





                @ŁukaszZaroda In that case you are going to have to define "safe". Normally "I want to blow away something that a daemon is configured to keep" is incompatible with "safe". If you want to force it just shut down the service and zero out the log files. If you want it to work normally you should define the parameters in your question better. What do you mean by "safe"?

                – Caleb
                Jun 27 '14 at 12:17











              • By safe, I mean that after clearing it will work as usual, just starting from the new place.

                – Łukasz Zaroda
                Jun 27 '14 at 12:19






              • 5





                It may be not typical situation but sometimes it is necessary to delete old logs due to some systemd's bugs, e.g. bbs.archlinux.org/viewtopic.php?pid=1173031#p1173031

                – diffycat
                Jun 27 '14 at 15:57






              • 1





                To clean logs after a period of time rather than when they reach a certain size, you can set the parameter MaxRetentionSec instead of SystemMaxUse. See man journald.conf for more details.

                – joelostblom
                Mar 29 '18 at 13:08








              10




              10





              Ok, but there are also untypical situations. I know that most of them is just aesthetics as a reason, but aesthetics is a valid reason for human being ;) .

              – Łukasz Zaroda
              Jun 27 '14 at 12:08





              Ok, but there are also untypical situations. I know that most of them is just aesthetics as a reason, but aesthetics is a valid reason for human being ;) .

              – Łukasz Zaroda
              Jun 27 '14 at 12:08




              2




              2





              @ŁukaszZaroda In that case you are going to have to define "safe". Normally "I want to blow away something that a daemon is configured to keep" is incompatible with "safe". If you want to force it just shut down the service and zero out the log files. If you want it to work normally you should define the parameters in your question better. What do you mean by "safe"?

              – Caleb
              Jun 27 '14 at 12:17





              @ŁukaszZaroda In that case you are going to have to define "safe". Normally "I want to blow away something that a daemon is configured to keep" is incompatible with "safe". If you want to force it just shut down the service and zero out the log files. If you want it to work normally you should define the parameters in your question better. What do you mean by "safe"?

              – Caleb
              Jun 27 '14 at 12:17













              By safe, I mean that after clearing it will work as usual, just starting from the new place.

              – Łukasz Zaroda
              Jun 27 '14 at 12:19





              By safe, I mean that after clearing it will work as usual, just starting from the new place.

              – Łukasz Zaroda
              Jun 27 '14 at 12:19




              5




              5





              It may be not typical situation but sometimes it is necessary to delete old logs due to some systemd's bugs, e.g. bbs.archlinux.org/viewtopic.php?pid=1173031#p1173031

              – diffycat
              Jun 27 '14 at 15:57





              It may be not typical situation but sometimes it is necessary to delete old logs due to some systemd's bugs, e.g. bbs.archlinux.org/viewtopic.php?pid=1173031#p1173031

              – diffycat
              Jun 27 '14 at 15:57




              1




              1





              To clean logs after a period of time rather than when they reach a certain size, you can set the parameter MaxRetentionSec instead of SystemMaxUse. See man journald.conf for more details.

              – joelostblom
              Mar 29 '18 at 13:08





              To clean logs after a period of time rather than when they reach a certain size, you can set the parameter MaxRetentionSec instead of SystemMaxUse. See man journald.conf for more details.

              – joelostblom
              Mar 29 '18 at 13:08











              16














              Michael's answer is missing one thing: vacuuming only removes archived journal files, not active ones. To get rid of everything, you need to rotate the files first so that recent entries are moved to inactive files.



              So, the complete answer to remove all entries seems to be



              journalctl --rotate
              journalctl --vacuum-time=1s


              (Note that you cannot combine this into one journalctl command.)



              By the way, some distributions have journald configured so that it writes logs to disk (/var/log/journal) while others keep logs in memory (/run/log/journal). I expect that in some cases it may be necessary to use journalctl --flush first to get everything removed.



              If you don't have --rotate in your version, you can use the --since argument to filter entries:



              --since "2019-01-30 14:00:00"
              --since today





              share|improve this answer


























              • journalctl: unrecognized option '--rotate'

                – stiv
                Oct 7 '18 at 12:22






              • 1





                while I get what the other answers are approaching (long term strategy) - the question is simple: how do you clear logs now (maybe you're not interested in the long term for your current task). This answers that question without making other assumptions and adds other great value to understanding journalctl. This should be the answer.

                – Marc
                Oct 20 '18 at 15:39
















              16














              Michael's answer is missing one thing: vacuuming only removes archived journal files, not active ones. To get rid of everything, you need to rotate the files first so that recent entries are moved to inactive files.



              So, the complete answer to remove all entries seems to be



              journalctl --rotate
              journalctl --vacuum-time=1s


              (Note that you cannot combine this into one journalctl command.)



              By the way, some distributions have journald configured so that it writes logs to disk (/var/log/journal) while others keep logs in memory (/run/log/journal). I expect that in some cases it may be necessary to use journalctl --flush first to get everything removed.



              If you don't have --rotate in your version, you can use the --since argument to filter entries:



              --since "2019-01-30 14:00:00"
              --since today





              share|improve this answer


























              • journalctl: unrecognized option '--rotate'

                – stiv
                Oct 7 '18 at 12:22






              • 1





                while I get what the other answers are approaching (long term strategy) - the question is simple: how do you clear logs now (maybe you're not interested in the long term for your current task). This answers that question without making other assumptions and adds other great value to understanding journalctl. This should be the answer.

                – Marc
                Oct 20 '18 at 15:39














              16












              16








              16







              Michael's answer is missing one thing: vacuuming only removes archived journal files, not active ones. To get rid of everything, you need to rotate the files first so that recent entries are moved to inactive files.



              So, the complete answer to remove all entries seems to be



              journalctl --rotate
              journalctl --vacuum-time=1s


              (Note that you cannot combine this into one journalctl command.)



              By the way, some distributions have journald configured so that it writes logs to disk (/var/log/journal) while others keep logs in memory (/run/log/journal). I expect that in some cases it may be necessary to use journalctl --flush first to get everything removed.



              If you don't have --rotate in your version, you can use the --since argument to filter entries:



              --since "2019-01-30 14:00:00"
              --since today





              share|improve this answer















              Michael's answer is missing one thing: vacuuming only removes archived journal files, not active ones. To get rid of everything, you need to rotate the files first so that recent entries are moved to inactive files.



              So, the complete answer to remove all entries seems to be



              journalctl --rotate
              journalctl --vacuum-time=1s


              (Note that you cannot combine this into one journalctl command.)



              By the way, some distributions have journald configured so that it writes logs to disk (/var/log/journal) while others keep logs in memory (/run/log/journal). I expect that in some cases it may be necessary to use journalctl --flush first to get everything removed.



              If you don't have --rotate in your version, you can use the --since argument to filter entries:



              --since "2019-01-30 14:00:00"
              --since today






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Jan 30 at 22:23









              David I.

              1514




              1514










              answered Jul 23 '18 at 9:48









              Jan WarchołJan Warchoł

              476419




              476419













              • journalctl: unrecognized option '--rotate'

                – stiv
                Oct 7 '18 at 12:22






              • 1





                while I get what the other answers are approaching (long term strategy) - the question is simple: how do you clear logs now (maybe you're not interested in the long term for your current task). This answers that question without making other assumptions and adds other great value to understanding journalctl. This should be the answer.

                – Marc
                Oct 20 '18 at 15:39



















              • journalctl: unrecognized option '--rotate'

                – stiv
                Oct 7 '18 at 12:22






              • 1





                while I get what the other answers are approaching (long term strategy) - the question is simple: how do you clear logs now (maybe you're not interested in the long term for your current task). This answers that question without making other assumptions and adds other great value to understanding journalctl. This should be the answer.

                – Marc
                Oct 20 '18 at 15:39

















              journalctl: unrecognized option '--rotate'

              – stiv
              Oct 7 '18 at 12:22





              journalctl: unrecognized option '--rotate'

              – stiv
              Oct 7 '18 at 12:22




              1




              1





              while I get what the other answers are approaching (long term strategy) - the question is simple: how do you clear logs now (maybe you're not interested in the long term for your current task). This answers that question without making other assumptions and adds other great value to understanding journalctl. This should be the answer.

              – Marc
              Oct 20 '18 at 15:39





              while I get what the other answers are approaching (long term strategy) - the question is simple: how do you clear logs now (maybe you're not interested in the long term for your current task). This answers that question without making other assumptions and adds other great value to understanding journalctl. This should be the answer.

              – Marc
              Oct 20 '18 at 15:39











              14














              On Arch linux, the closest I got was:




              • Edit /etc/systemd/journald.conf to set SystemMaxUse=1M

              • Restarting journal: sudo systemctl restart systemd-journald

              • Resetting SystemMaxUse=200M

              • Re-Restarting the journal


              On my system, each journal file is 8MB, and the above cleared all but 3, bringing the total size to ~25MB.



              My use-case was disabling CoW for BTRFS (just for the journal directory and subdirectories): sudo chattr +C /var/log/journal/*. The problem is, the attribute is only set on newly-created files, thus the desire to flush the journal.






              share|improve this answer



















              • 4





                Your use-case was actually not needed. The point of disabling CoW on the journal is that it is frequently written to. That is not the case for the old rotated journal files, they just sit there.

                – Hjulle
                Mar 31 '15 at 10:03






              • 1





                I've set SystemMaxUse=1K, restarted systemd-journald, but journalctl still shows entries I want gone. How is this progress from flat text files?

                – Dan Dascalescu
                Sep 10 '16 at 4:18
















              14














              On Arch linux, the closest I got was:




              • Edit /etc/systemd/journald.conf to set SystemMaxUse=1M

              • Restarting journal: sudo systemctl restart systemd-journald

              • Resetting SystemMaxUse=200M

              • Re-Restarting the journal


              On my system, each journal file is 8MB, and the above cleared all but 3, bringing the total size to ~25MB.



              My use-case was disabling CoW for BTRFS (just for the journal directory and subdirectories): sudo chattr +C /var/log/journal/*. The problem is, the attribute is only set on newly-created files, thus the desire to flush the journal.






              share|improve this answer



















              • 4





                Your use-case was actually not needed. The point of disabling CoW on the journal is that it is frequently written to. That is not the case for the old rotated journal files, they just sit there.

                – Hjulle
                Mar 31 '15 at 10:03






              • 1





                I've set SystemMaxUse=1K, restarted systemd-journald, but journalctl still shows entries I want gone. How is this progress from flat text files?

                – Dan Dascalescu
                Sep 10 '16 at 4:18














              14












              14








              14







              On Arch linux, the closest I got was:




              • Edit /etc/systemd/journald.conf to set SystemMaxUse=1M

              • Restarting journal: sudo systemctl restart systemd-journald

              • Resetting SystemMaxUse=200M

              • Re-Restarting the journal


              On my system, each journal file is 8MB, and the above cleared all but 3, bringing the total size to ~25MB.



              My use-case was disabling CoW for BTRFS (just for the journal directory and subdirectories): sudo chattr +C /var/log/journal/*. The problem is, the attribute is only set on newly-created files, thus the desire to flush the journal.






              share|improve this answer













              On Arch linux, the closest I got was:




              • Edit /etc/systemd/journald.conf to set SystemMaxUse=1M

              • Restarting journal: sudo systemctl restart systemd-journald

              • Resetting SystemMaxUse=200M

              • Re-Restarting the journal


              On my system, each journal file is 8MB, and the above cleared all but 3, bringing the total size to ~25MB.



              My use-case was disabling CoW for BTRFS (just for the journal directory and subdirectories): sudo chattr +C /var/log/journal/*. The problem is, the attribute is only set on newly-created files, thus the desire to flush the journal.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Feb 11 '15 at 23:53









              helmingstayhelmingstay

              15913




              15913








              • 4





                Your use-case was actually not needed. The point of disabling CoW on the journal is that it is frequently written to. That is not the case for the old rotated journal files, they just sit there.

                – Hjulle
                Mar 31 '15 at 10:03






              • 1





                I've set SystemMaxUse=1K, restarted systemd-journald, but journalctl still shows entries I want gone. How is this progress from flat text files?

                – Dan Dascalescu
                Sep 10 '16 at 4:18














              • 4





                Your use-case was actually not needed. The point of disabling CoW on the journal is that it is frequently written to. That is not the case for the old rotated journal files, they just sit there.

                – Hjulle
                Mar 31 '15 at 10:03






              • 1





                I've set SystemMaxUse=1K, restarted systemd-journald, but journalctl still shows entries I want gone. How is this progress from flat text files?

                – Dan Dascalescu
                Sep 10 '16 at 4:18








              4




              4





              Your use-case was actually not needed. The point of disabling CoW on the journal is that it is frequently written to. That is not the case for the old rotated journal files, they just sit there.

              – Hjulle
              Mar 31 '15 at 10:03





              Your use-case was actually not needed. The point of disabling CoW on the journal is that it is frequently written to. That is not the case for the old rotated journal files, they just sit there.

              – Hjulle
              Mar 31 '15 at 10:03




              1




              1





              I've set SystemMaxUse=1K, restarted systemd-journald, but journalctl still shows entries I want gone. How is this progress from flat text files?

              – Dan Dascalescu
              Sep 10 '16 at 4:18





              I've set SystemMaxUse=1K, restarted systemd-journald, but journalctl still shows entries I want gone. How is this progress from flat text files?

              – Dan Dascalescu
              Sep 10 '16 at 4:18











              10














              A very brute force method to clean the entire log:



              $ sudo journalctl --vacuum-time=1seconds


              You can also use --vacuum-size as Michael mentoined.






              share|improve this answer



















              • 5





                Didn't work. Entries for 15 minutes ago still show up, even after running systemctl restart systemd-journald.

                – Dan Dascalescu
                Sep 10 '16 at 4:15






              • 1





                Same here. This didn't work for me either. I'm running CentOS7.

                – jersey bean
                Aug 3 '17 at 1:55
















              10














              A very brute force method to clean the entire log:



              $ sudo journalctl --vacuum-time=1seconds


              You can also use --vacuum-size as Michael mentoined.






              share|improve this answer



















              • 5





                Didn't work. Entries for 15 minutes ago still show up, even after running systemctl restart systemd-journald.

                – Dan Dascalescu
                Sep 10 '16 at 4:15






              • 1





                Same here. This didn't work for me either. I'm running CentOS7.

                – jersey bean
                Aug 3 '17 at 1:55














              10












              10








              10







              A very brute force method to clean the entire log:



              $ sudo journalctl --vacuum-time=1seconds


              You can also use --vacuum-size as Michael mentoined.






              share|improve this answer













              A very brute force method to clean the entire log:



              $ sudo journalctl --vacuum-time=1seconds


              You can also use --vacuum-size as Michael mentoined.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Jul 6 '15 at 18:18









              LantiLanti

              28029




              28029








              • 5





                Didn't work. Entries for 15 minutes ago still show up, even after running systemctl restart systemd-journald.

                – Dan Dascalescu
                Sep 10 '16 at 4:15






              • 1





                Same here. This didn't work for me either. I'm running CentOS7.

                – jersey bean
                Aug 3 '17 at 1:55














              • 5





                Didn't work. Entries for 15 minutes ago still show up, even after running systemctl restart systemd-journald.

                – Dan Dascalescu
                Sep 10 '16 at 4:15






              • 1





                Same here. This didn't work for me either. I'm running CentOS7.

                – jersey bean
                Aug 3 '17 at 1:55








              5




              5





              Didn't work. Entries for 15 minutes ago still show up, even after running systemctl restart systemd-journald.

              – Dan Dascalescu
              Sep 10 '16 at 4:15





              Didn't work. Entries for 15 minutes ago still show up, even after running systemctl restart systemd-journald.

              – Dan Dascalescu
              Sep 10 '16 at 4:15




              1




              1





              Same here. This didn't work for me either. I'm running CentOS7.

              – jersey bean
              Aug 3 '17 at 1:55





              Same here. This didn't work for me either. I'm running CentOS7.

              – jersey bean
              Aug 3 '17 at 1:55











              9














              Since --vacuum-time and --vacuum-size didn't do a thing for me I did the following:



              $ sudo find /var/log/journal -name "*.journal" | xargs sudo rm 
              $ sudo systemctl restart systemd-journald


              It's not right, but it worked.






              share|improve this answer


























              • On Debian Jessie, the path is /run/log.

                – Synchro
                Feb 12 '18 at 18:23











              • only this helped me !

                – T.Todua
                Nov 27 '18 at 10:49


















              9














              Since --vacuum-time and --vacuum-size didn't do a thing for me I did the following:



              $ sudo find /var/log/journal -name "*.journal" | xargs sudo rm 
              $ sudo systemctl restart systemd-journald


              It's not right, but it worked.






              share|improve this answer


























              • On Debian Jessie, the path is /run/log.

                – Synchro
                Feb 12 '18 at 18:23











              • only this helped me !

                – T.Todua
                Nov 27 '18 at 10:49
















              9












              9








              9







              Since --vacuum-time and --vacuum-size didn't do a thing for me I did the following:



              $ sudo find /var/log/journal -name "*.journal" | xargs sudo rm 
              $ sudo systemctl restart systemd-journald


              It's not right, but it worked.






              share|improve this answer















              Since --vacuum-time and --vacuum-size didn't do a thing for me I did the following:



              $ sudo find /var/log/journal -name "*.journal" | xargs sudo rm 
              $ sudo systemctl restart systemd-journald


              It's not right, but it worked.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Nov 27 '18 at 11:55









              Jeff Schaller

              41.2k1056131




              41.2k1056131










              answered Dec 30 '16 at 22:08









              MattMatt

              24435




              24435













              • On Debian Jessie, the path is /run/log.

                – Synchro
                Feb 12 '18 at 18:23











              • only this helped me !

                – T.Todua
                Nov 27 '18 at 10:49





















              • On Debian Jessie, the path is /run/log.

                – Synchro
                Feb 12 '18 at 18:23











              • only this helped me !

                – T.Todua
                Nov 27 '18 at 10:49



















              On Debian Jessie, the path is /run/log.

              – Synchro
              Feb 12 '18 at 18:23





              On Debian Jessie, the path is /run/log.

              – Synchro
              Feb 12 '18 at 18:23













              only this helped me !

              – T.Todua
              Nov 27 '18 at 10:49







              only this helped me !

              – T.Todua
              Nov 27 '18 at 10:49













              0














              journal-ctl -b-0 will show only from the most recent boot. You can also use -1, -2 etc. Your horrendous day is still there but you won't have to see it, unless you need to.






              share|improve this answer




























                0














                journal-ctl -b-0 will show only from the most recent boot. You can also use -1, -2 etc. Your horrendous day is still there but you won't have to see it, unless you need to.






                share|improve this answer


























                  0












                  0








                  0







                  journal-ctl -b-0 will show only from the most recent boot. You can also use -1, -2 etc. Your horrendous day is still there but you won't have to see it, unless you need to.






                  share|improve this answer













                  journal-ctl -b-0 will show only from the most recent boot. You can also use -1, -2 etc. Your horrendous day is still there but you won't have to see it, unless you need to.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jun 1 '15 at 11:11









                  DavidDavid

                  91




                  91























                      0














                      Both --rotate and --vacuum-time=1s didn't work for me on CentOS. I was able to clear it like this:



                      sudo rm -rf /run/log/journal/*





                      share|improve this answer




























                        0














                        Both --rotate and --vacuum-time=1s didn't work for me on CentOS. I was able to clear it like this:



                        sudo rm -rf /run/log/journal/*





                        share|improve this answer


























                          0












                          0








                          0







                          Both --rotate and --vacuum-time=1s didn't work for me on CentOS. I was able to clear it like this:



                          sudo rm -rf /run/log/journal/*





                          share|improve this answer













                          Both --rotate and --vacuum-time=1s didn't work for me on CentOS. I was able to clear it like this:



                          sudo rm -rf /run/log/journal/*






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Oct 7 '18 at 12:30









                          stivstiv

                          2152516




                          2152516






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Unix & Linux Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f139513%2fhow-to-clear-journalctl%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              How to make a Squid Proxy server?

                              Is this a new Fibonacci Identity?

                              19世紀