Logs grow quietly. logrotate cuts, compresses and drops old files based on a rule.
Steps
On Ubuntu it is usually installed. Check the binary:
logrotate --versionCreate a rule for your app (example):
sudo nano /etc/logrotate.d/my-appExample contents:
/var/log/my-app/*.log {dailyrotate 14compressdelaycompressmissingoknotifemptycopytruncate}Dry-run, then force one rotation:
sudo logrotate -d /etc/logrotate.d/my-appsudo logrotate -f /etc/logrotate.d/my-app
Tips
- copytruncate avoids restarting a process that keeps writing the same file.
- Check df -h /var if the disk grows — often unrotated logs.
ext step
VMe disk with room for logs and backups: Xernode Cloud VPS.