How to configure log rotation with logrotate
Updated 11/29/2026
Without rotation, a log file can reach gigabytes and fill the disk. logrotate solves this by automatically archiving and deleting old logs.
It is already installed
Most distributions ship logrotate preinstalled, with rules for system services. You configure it for your own applications.
Example configuration
Create /etc/logrotate.d/my-app:
/var/log/my-app/*.log {
daily
rotate 14
compress
delaycompress
missingok
notifempty
copytruncate
}
What it means
- daily: rotate daily.
- rotate 14: keep 14 archives (two weeks).
- compress: gzip archives to save space.
- copytruncate: useful for apps that keep the file open.
Test
logrotate -d /etc/logrotate.d/my-app # simulate
logrotate -f /etc/logrotate.d/my-app # force now
Combine with space monitoring, see disk monitoring, so a full disk never surprises you.
Put this guide into practice on your own VPS
EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.
See pricingRelated tutorials
A real-time server status dashboard with dashdot
CPU, memory, storage and network at a glance, behind a password. What dashdot shows, how to customise it and where it stops.
Updated 11/29/2026Monitoring & loggingHow to monitor a website and SSL expiry
Do not let your site go down or your SSL certificate expire without knowing. Here is how to track them automatically.
Updated 11/29/2026Monitoring & loggingHow to monitor database performance
See slow queries, connections and database usage, to keep it fast.
Updated 11/29/2026