LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-26-2011, 09:53 AM   #1
samanp
LQ Newbie
 
Registered: Dec 2005
Posts: 22

Rep: Reputation: 0
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.
 
Old 12-26-2011, 10:01 AM   #2
fukawi1
Member
 
Registered: Apr 2009
Location: Melbourne
Distribution: Fedora & CentOS
Posts: 854

Rep: Reputation: 190Reputation: 190
I think what you are looking for is logrotate.

"man logrotate" for more info.
 
Old 12-26-2011, 11:40 AM   #3
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Debian, OS X
Posts: 1,298

Rep: Reputation: 102Reputation: 102
Lightbulb

You can simply schedule below line in crontab

Code:
find /your/dir -mtime +7 | xargs gzip
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Script to compress pnmanojshenoy Linux - Newbie 2 06-07-2010 02:26 PM
script to compress a directory and then delete older than 7 days replica88 Linux - General 3 02-03-2010 08:21 PM
How to make/configure script to extract, ecit and compress initrd.gz ?? linus72 Linux - General 14 10-22-2009 07:31 PM
Logrotate: compress logs in a temp directory gbratig AIX 3 04-12-2008 11:42 PM
script needed to compress files kingkhankk Linux - General 2 03-04-2008 12:20 PM


All times are GMT -5. The time now is 04:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration