Unix - Manual vs Automatic Log Rotation
1. Manual Log Rotation
What It Is
Manual rotation means a system administrator rotates log files by hand whenever needed.
How It Is Done
-
Renaming log files
-
Creating new log files
-
Compressing or deleting old logs manually
Example
mv /var/log/syslog /var/log/syslog.1
touch /var/log/syslog
gzip /var/log/syslog.1
Advantages
✔ Full control over rotation
✔ Useful for emergency situations
✔ Simple for very small systems
Disadvantages
❌ Time-consuming
❌ Error-prone
❌ Easy to forget
❌ Not scalable
❌ Risk of disk full issues
2. Automatic Log Rotation
What It Is
Automatic rotation uses tools like logrotate or systemd-journal to rotate logs automatically based on rules.
How It Is Done
-
Runs via cron or systemd timer
-
Rotates logs based on:
-
Time (daily, weekly)
-
Size (100MB, etc.)
-
-
Compresses and deletes logs automatically
Example (logrotate)
/var/log/syslog {
daily
rotate 7
compress
}
Advantages
✔ Fully automated
✔ Prevents disk space issues
✔ Consistent and reliable
✔ Suitable for servers
✔ Supports compression and retention
Disadvantages
❌ Requires initial configuration
❌ Misconfiguration may cause loss of logs
3. Key Differences (Tabular Comparison)
| Feature | Manual Rotation | Automatic Rotation |
|---|---|---|
| Human involvement | Required | Not required |
| Tools used | Basic shell commands | logrotate / journalctl |
| Time-based rotation | No | Yes |
| Size-based rotation | No | Yes |
| Compression | Manual | Automatic |
| Risk of errors | High | Low |
| Scalability | Poor | Excellent |
| Used in production | Rare | Common |
4. Security & Reliability Comparison
| Aspect | Manual | Automatic |
|---|---|---|
| Disk full protection | Weak | Strong |
| Log integrity | Medium | High |
| Audit readiness | Poor | Good |
| Attack resilience | Low | High |
5. When to Use Each
Use Manual Rotation When:
-
Debugging or testing
-
One-time emergency cleanup
-
Very small or temporary systems
Use Automatic Rotation When:
-
Production servers
-
Multi-user systems
-
Security-sensitive environments
-
Compliance requirements