Solved

Compressing Archived APache Log Files By date

Posted on 2003-12-10
4
350 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sort command HPUX 11 81
Unix Command -- Challenging  question 7 96
what is the difference between "sudo su" and "su - root" 6 126
Authenticate using sesu from script 7 56
Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.

856 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