27.5. logroll
A few of the logs on my system grow quite quickly. Having to manually check the size of these logs for file sizes and then roll over the log (usually with a data stamp) gets tedious. Therefore I decided it was time I set up a script to do this automatically. The script would run from cron, and if any of the logs reached a certain size, the guilty log would be rolled over and a new log file created.
The script can easily be amended to suit other logs. For my system logs, I use another script, which is run once a week and truncates the log files. If I need to go back over any period I just check my backup; as I run a 16-week cycle this is no problem.
A size limit is defined in the variable BLOCK_LIMIT. This figure is the block size, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access