0Pricing
Linux Command Line & Bash Scripting Mastery · Lesson

Automated Log Rotation & Cleanup

Keep disks healthy by automating log rotation and old-file cleanup with logrotate and scheduled find-based scripts.

The Problem of Growing Logs

Long-running services write logs forever. Without management they fill the disk and crash the system. Rotation and cleanup keep them in check.

du -sh /var/log/*

What Log Rotation Does

Rotation renames the current log, starts a fresh empty one, and keeps a limited number of older compressed copies.

  • app.log becomes app.log.1
  • old copies get gzipped
  • the oldest are deleted

All lessons in this course

  1. Scheduling Tasks with Cron
  2. Automating System Administration
  3. Advanced Scripting Project
  4. Automated Log Rotation & Cleanup
← Back to Linux Command Line & Bash Scripting Mastery