Chapter 14. Aging, Archiving, and Deleting Files
Files grow. It's a fact of life. There are log files in /var/log
(they may be in /var/adm
, or somewhere else, depending on your system). In my mail directory I have saved-messages
, and sent-mail
, and files for the various mailing lists I'm on. In my Chess
directory, fics.pgn
stores every game of chess I play online. Files in my News
directory swell with my Usenet posts.
Most modern Unix systems offer a log rotation program that can be configured to suit many of your needs. Files can be rotated daily, weekly, monthly, or whenever they reach a certain size. They can be compressed or not, as you wish. Traditionally, log rotation files have been numbered, with the most recent always having a suffix of ...
Get Shell Scripting Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.