O'Reilly logo

Linux and Unix Shell Programming by David Tansley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required