Skip to main content

Log Rotation

Learning Focus

By the end of this lesson you will know how to configure log rotation to manage disk space effectively.

Why Log Rotation Matters

Without rotation, log files grow indefinitely and can fill the disk, causing server failures.

Built-in Rotation (WebAdmin)

  1. Server ConfigurationLogRolling Size
  2. Set a maximum file size (e.g., 100M for 100 megabytes)
  3. When the log reaches this size, OpenLiteSpeed creates a new log file

System-Level Rotation (logrotate)

cat > /etc/logrotate.d/openlitespeed << 'EOF'
/usr/local/lsws/logs/*.log {
daily
missingok
rotate 14
compress
notifempty
postrotate
/usr/local/lsws/bin/lswsctrl restart
endscript
}
EOF

Monitoring Log Size

# Check current log sizes
du -sh /usr/local/lsws/logs/*

# Set up a simple alert
find /usr/local/lsws/logs/ -size +500M -exec echo "WARNING: Large log file: {}" \;

Key Takeaways

  • Configure rotation by size to prevent disk exhaustion.
  • Use either built-in rolling or system logrotate.
  • Monitor log sizes, especially on busy servers.

What's Next