Solved

Compressing Archived APache Log Files By date

Posted on 2003-12-10
4
354 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
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.

726 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