How to Delete Old Journal Logs in Ubuntu
If you’re running Ubuntu, you might accumulate a large amount of journal logs over time. These logs can take up valuable disk space. Fortunately, you can easily delete old journal logs to free up space on your system. Here’s how you can do it using the journalctl command with the --vacuum-time option.
Deleting Old Journal Logs
To delete old journal logs in Ubuntu, follow these steps:
-
Open a terminal window. You can do this by pressing
Ctrl+Alt+Tor searching for “Terminal” in the application menu. -
In the terminal, use the
journalctlcommand with the--vacuum-timeoption to specify the time period for which you want to keep the logs. For example, to delete journal logs older than 30 days, you can run the following command:1sudo journalctl --vacuum-time=30dThe
30dparameter specifies that logs older than 30 days should be deleted. You can adjust the number of days to your preference. -
You will be prompted to confirm the action. Type
yand press Enter to proceed with the deletion. -
The command will clean up the old journal logs, and you’ll see a summary of how much disk space was freed.
Checking Disk Space Usage
If you want to check how much disk space your journal logs are currently occupying before and after the cleanup, you can use the journalctl command with the --disk-usage option:
|
|
This command will display the current disk usage of your journal logs.
That’s it! You’ve successfully deleted old journal logs on your Ubuntu system, freeing up disk space in the process. Regularly cleaning up old logs can help keep your system running smoothly and prevent unnecessary disk space usage.