script to find and compress old logs that are not compresses
we have a system that generates large logs in hourly basis with the name format ex: addressprint_log.20111226000000. The system is supposed to compress logs older than 7 days but sometimes it miss logs filling up space.
I started to use gzip with find command but it goes through all logs from the beginning and passing ones already zipped. Can someone please help with a script to find and compress logs older than 7 days which are not already compresses? thanks in advance. |
I think what you are looking for is logrotate.
"man logrotate" for more info. |
You can simply schedule below line in crontab
Code:
find /your/dir -mtime +7 | xargs gzip |
All times are GMT -5. The time now is 11:36 AM. |