logrotate
Installation
SKILL.md
Identity
- Binary:
/usr/sbin/logrotate - Config:
/etc/logrotate.conf - Drop-in dir:
/etc/logrotate.d/(each file rotates one or more applications) - State file:
/var/lib/logrotate/status(tracks last rotation time per log path) - Scheduler: run daily via
/etc/cron.daily/logrotateorlogrotate.timer(systemd) - Distro install:
apt install logrotate/dnf install logrotate
Key Operations
| Operation | Command |
|---|---|
| Test config (dry-run, verbose) | logrotate -d /etc/logrotate.conf |
| Test a specific drop-in config | logrotate -d /etc/logrotate.d/nginx |
| Force rotation now (ignore schedule) | logrotate -f /etc/logrotate.conf |
| Force-rotate a single config | logrotate -f /etc/logrotate.d/myapp |
| Run with verbose output | logrotate -v /etc/logrotate.conf |
| Combine force + verbose | logrotate -vf /etc/logrotate.conf |
| Check state file (last rotation times) | cat /var/lib/logrotate/status |
Related skills