LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   script to find and compress old logs that are not compresses (https://www.linuxquestions.org/questions/linux-newbie-8/script-to-find-and-compress-old-logs-that-are-not-compresses-920563/)

samanp 12-26-2011 08:53 AM

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.

fukawi1 12-26-2011 09:01 AM

I think what you are looking for is logrotate.

"man logrotate" for more info.

vikas027 12-26-2011 10:40 AM

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.