Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Every day I would like to run logrotate on /var/trafficap/captured/arch/ and zip all the zip packages I have for each day ( its 1 package.zip with a name like this :

log_from_2012_08_14-11:57:12_To_2012_09_14-13:57:12.zip 

For each 2 hours of trafic, and when I get to the daily schedule time of lograte he would create the log_2012_08_14.zip(sum of all todays .zip) and move it it everyday to a different dir just like this:

/var/trafficap/captured/arch/*zip {
daily
compress
prerotate
if [[ ! -d `date +%F` ]]
then
 mkdir `date +%F`
fi
endscript
}

but i don't know how to say "Logrotate please zip this files to the datedtoday.zip to the directory that is equal to $datedtoday that I created on the pre script\conf file"

share|improve this question

2 Answers 2

What about looking at the problem from the other way around? How about doing a postrotate routine that moves the file (after being rotated) to the appropriate destination with the appropriate name.

share|improve this answer
    
can be a solution but for that the question still remains how do i say "logrotate move the compress\rotated package to this dir that have the date of today" and then the day after do the same for all the days forever –  drd0sPy Oct 31 '12 at 18:02

Straight from logrotate's man page

olddir directory

Logs are moved into directory for rotation. The directory must be on the same physical device as the log file being rotated, and is assumed to be relative to the directory holding the log file unless an absolute path name is specified. When this option is used all old versions of the log end up in directory. This option may be overridden by the noolddir option.

share|improve this answer
    
hmmm how can i set the olddir to be dynamic with each day ... like how to make him do assume this value : date %h%m%d –  drd0sPy Oct 31 '12 at 19:46
    
If your script assigns 'date %h%m%d' to a variable, then you should be able to use it in logrotate. But this is a guess since I never used it that way –  Alex Oct 31 '12 at 19:51
    
well it doesnt work but i did it like this : code /home/drd0s/teste/*zip { daily compress postrotate a=$(date +%Y-%m-%d) pastadhoje=$(ls -f | grep -c $a) if [ "$pastadhoje" -eq 0 ] then mkdir $a fi mv *.gz $a mv *.zip.1 $a endscript } code –  drd0sPy Nov 2 '12 at 17:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.