Rotating Log Files
Log files are great, but sometimes they can get unwieldy as time passes and more information is logged. Rotating log files prevents that problem. Rotating a log file means to archive the current log file, start a fresh log, and delete older log files. This means you always have a current log file to peruse, the previous log file, and that the log files never grow too large.
Typically, log rotation is set up by an administrator to happen nightly, at a time when the system is not being heavily used. This is done with a utility called
logrotate, running as a
cron job (
cron is described in Chapter 13, “Automating Tasks and Shell Scripting”).
Ubuntu comes with
logrotate installed. There is a
cron job already set as well. You can ...