Originally I thought log rotation would be easy with the perl’s module Logfile:Rotate, but now the requirement changed to appending the date to the filename of the log file.
I need to:
- Append the filename rotated (daily) with date.
- Zip the log files older than 10 days.
- Delete log files older than 30 days.
- Logs to be rotated in a directory (i.e. ../logs)
I tried Python’s logging.handlers.TimedRotatingFileHandler, but it creates new empty log files on cron execution. I think it’s meant for a process that’s continuous and not per interval cron execution.
I’m open to any programming (scripting) language for easy log rotation.
Anyone got better ideas?
Not meant to ask for code. Just suggestions.
logrotate utility on most of *nix distros available today support following options of your interest: