Stop apt from keeping those massive historical log files forever

Package Management (Apt/Dnf/Pacman Internals)

Stop apt from keeping those massive historical log files forever

🧩 The Challenge

You ever run a `df -h` on an aging server and wonder why /var/log is eating up gigabytes of space, only to find that apt has been dutifully saving every single transaction log since the dawn of time? It’s a massive waste of disk space for logs nobody looks at unless the world is already ending.

💡 The Fix

Use a logrotate configuration snippet to force apt to clear out those ancient history files so your partition doesn’t fill up while you aren’t looking. You really only need the last few months of logs, if that.

echo '/var/log/apt/history.log {
rotate 12
monthly
compress
missingok
notifempty
}' > /etc/logrotate.d/apt

⚙️ Why It Works

Setting up a specific config file in /etc/logrotate.d tells the system’s log management tool to treat those files like any other system log, forcing them to roll over instead of growing until they hit the physical limits of your drive. Once you place that file, the internal logic takes care of the cleanup on the next cron cycle.

🚀 Pro-Tip: Check /var/log/apt/term.log too if your servers have been running for years without a clean install.

Linux Tips & Tricks | © ngelinux.com | 8/22/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted