Solved

Compressing Archived APache Log Files By date

Posted on 2003-12-10
4
346 Views
Last Modified: 2013-12-27
I wasn't sure which place to ask this question, since it involves basic Solaris compression, but here goes:

Background:
I am running RedHat Stronghold Apache 4 on SUn Solaris 9 servers. I use the rotatelogs command inside the CustomLog format to rotate the httpd access logs daily and this works as it should.

Now the question:
How can I write a script that will either jar, tar, or zip these archived files by date. (This will be set as a cron job that will run daily) In other words, take the individual files that are, say, over 10 days old and zip each one separately into its own zip file to be moved to a different archive area?

0
Comment
Question by:boucherc
  • 2
4 Comments
 

Author Comment

by:boucherc
ID: 9913198
Just a comment, the log files are named as follows:

%y%m%d-access.log
0
 
LVL 18

Expert Comment

by:liddler
ID: 9913232
find /path/to/log -mtime +10 -exec zip {} \;

That files any files in the /path/to/log directory that haven't been modified for 10 days and zips them
Will that do?
0
 
LVL 38

Accepted Solution

by:
yuzh earned 250 total points
ID: 9917574
use gzip you can get better compression. It is important to soecify the file type with
the find command:

find /path-to/log -type f -mtime +10 -exec gzip {} \;

or

find /path-to/log -type f -mtime +10 -exec compress {} \;

To move the files to a different dir:

For gzip
cd /path-to/log
mv *.gz /another-dir

or (For "compreess")
mv *.Z /another-dir

You can put the about commands in your script.
0
 

Author Comment

by:boucherc
ID: 9919778
Thanks for your help. The answer from yuzh was just what I needed. I completely forget about executing commands inside a find command. Trying to get out of my Microsoft habits, it'll take time.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now