Solved

Compressing Archived APache Log Files By date

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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
prtdiag report hdd failure 10 151
removing nim resources 5 54
MarkLogic 1 79
remove one line from a file in solaris 8 29
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 …
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

810 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