CloudLinux.ro
Monitoring & logging

How to configure log rotation with logrotate

Updated 7/20/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 pricing

Related tutorials