Practical steps to change when and how logrotate rotates your log files. 16.11.2025 | reading time: 2 min Logrotate is the tool that keeps log files from filling disks; by changing its frequency you decide when logs roll, how many copies remain and whether they are compressed. Example: set daily rotation for an application log Create `/etc/logrotate.d/myapp` with a rule such as `/var/log/myapp.log { daily rotate 7 compress missingok notifempty create 0640 root adm postrotate systemctl restart myapp.service endscript }` then preview with `logrotate -d /etc/logrotate.conf` to see what would happen and force a rotation with `logrotate -f /etc/logrotate.conf`; after a forced run expect a rotated file like `/var/log/myapp.log.1` and the main file recreated with the specified mode. Tweak by size, age and scripts Beyond time-based options like daily, weekly and monthly you can use `size` to rotate when a file grows past a threshold and `maxage` to remove very old logs; control retention with `rotate`, move old logs with `olddir`, compress with `delaycompress` and run maintenance via `postrotate` or `sharedscripts`, and remember global settings live in `/etc/logrotate.conf` while individual packages drop fragments into `/etc/logrotate.d`. Rotate where logrotate cannot reach Journal logs are managed by systemd-journald (use `journalctl --vacuum-size` or a systemd timer) rather than logrotate, and centralized setups often forward logs with rsyslog or syslog-ng before applying file rotation policies on collectors. Keep testing and automate safely Regularly run `logrotate -d` for dry runs and use `-f` only when you understand consequences; combine a systemd timer or a cron job with configuration management to ensure consistent frequency across servers and to avoid accidental disk spikes during coordinated rotations. Keep logs predictable and manageable Set sensible defaults, test changes, and prefer small, frequent rotations for high-volume logs or size-based rules for bursty workloads; to deepen Linux logging skills consider further study and certification such as CompTIA Linux+ or LPIC-1, and try intensive exam preparation at bitsandbytes.academy. Join Bits & Bytes Academy First class LINUX exam preparation. utilities filesystem backup scripting troubleshooting