Friday, January 4, 2019

HowTo clear journalctl manually

HowTo clear journalctl manually

Before we start about, looking into the commands and usage, let us understand what exactly is journalctl. 

Web definition quotes journalctl as "a command for viewing logs collected by systemd. The systemd-journald service is responsible for systemd’s log collection, and it retrieves messages from the kernel, systemd services, and other sources.

These logs are gathered in a central location, which makes them easy to review. The log records in the journal are structured and indexed, and as a result journalctl is able to present your log information in a variety of useful formats"
As we all know, logs of any genre, grows in size, with time and usage, we need to plan a strategy to clear them from the system, thus ensuring of free space and log retention for analysis. This is called as enabling log rotation. We will see more about logrotation in another blog and for now, let us undertstand on how to clear off logs manually, which comes handy when in need of a quick resolutions
To see logs of a particular service, use as below.
                                             journalctl -u <<servicename>>
And yes, Linux documentations, will show you a lot other switches that you can use, but what has been shared here, is from experience and necessity. 
To clear the logs from command line, use as below.
                                           sudo journalctl --vaccum-size=1G

No comments:

Post a Comment