I recently had to create a custom log rotation strategy for a server I manage. The logs are very unique and frankly messy so using the built in logrotate wasn’t really an option. I decided that I wanted to mitigate the risk of filling up my HD with old logs, and that a month’s worth of logs would be enough. I created the following script (which is overly verbose, but helps readability) to archive my logs to a tar.gz and delete anything older than a month old. I create a Cron Job to run every week. TODO add exception or failure handling and tighten it all up a bit, but for now this is more than sufficient.