Prerequisites
Before configuring log rotation, make sure you have:
- SSH access to your VPS
- Root or sudo privileges
HestiaCP Default Log Rotation
HestiaCP automatically rotates logs using logrotate.
Check configuration:
cat /etc/logrotate.d/hestia
Customize Log Rotation for Domains
Create domain-specific logrotate config:
nano /etc/logrotate.d/example.com
Add:
/home/admin/logs/example.com/*.log {
daily
rotate 7
compress
delaycompress
missingok
notifempty
create 640 admin www-data
sharedscripts
postrotate
systemctl reload nginx > /dev/null 2>&1 || true
endscript
}
Manually Rotate Logs
logrotate -f /etc/logrotate.d/example.com
Test Log Rotation Configuration
logrotate -d /etc/logrotate.d/example.com
Log Rotation Parameters Explained
- daily - Rotate daily (weekly, monthly also available)
- rotate 7 - Keep 7 rotated logs
- compress - Gzip rotated logs
- delaycompress - Don't compress the most recent rotated log
- missingok - Don't error if log missing
- notifempty - Don't rotate empty logs
- create 640 - Create new log with permissions
Check Current Log Sizes
du -sh /home/admin/logs/*
Delete Old Logs Manually
find /home/admin/logs -name "*.log.*" -mtime +30 -delete
✅ Log rotation has been configured!