logrotate

Kaushal Shriyan kaushalshriyan at gmail.com
Thu Mar 4 10:20:39 UTC 2010


On Thu, Mar 4, 2010 at 3:13 PM, Ian Coetzee <ubuntu at iancoetzee.za.net> wrote:
> On 2010/03/04 11:27 AM, Kaushal Shriyan wrote:
>> On Thu, Mar 4, 2010 at 2:33 PM, Amedee Van Gasse (ub)
>> <amedee-ubuntu at amedee.be>  wrote:
>>
>>> On Thu, March 4, 2010 09:41, Kaushal Shriyan wrote:
>>>
>>>> Hi,
>>>>
>>>> is there a way to scp or rsync the files to a remote host older than
>>>> 15 days in the logrotate config ?
>>>>
>>> Yes, of course!
>>> Just add your scp or rsync stanza to the postrotate section of your
>>> logrotate config. man logrotate or google 'logrotate postrotate' for
>>> examples.
>>>
>>> --
>>> Amedee
>>>
>> Amedee,
>>
>> Let me rephrase the question.
>>
>> Is there a way to scp or rsync the files to a remote host older than
>> 15 days in the logrotate config and than delete it on localhost older
>> than 15 days, so that at a time only 15 days of logs are available on
>> localhost. ?
>>
>> Thanks,
>>
>> Kaushal
>>
>>
> The only way I can think of is using a cronjob calling a "find" script
> on a daily basis.
>
> Should look something like this (Note my "find" is a bit rusty, so dont
> take my code as gospel)
>
>  >for FILE in `find /var/log/ -atime +15
>  >do
>  > <insert magic here to do something with $FILE>
>  >done
>
> Use "man find" to fine the correct syntax :)
>
> Regards
> Ian
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>

Hi,

I have created a logrotate/postrotate config.

/usr/local/tomcat0-tata-gw52/logs/catalina.out {
        daily
        dateext
        missingok
        copytruncate
        rotate 15
        compress
        compresscmd /bin/gzip
        notifempty
postrotate
pastdate=$(date +%Y%m%d --date='15 days ago')
if [ -e /usr/local/tomcat0-tata-gw52/logs/catalina.out-${pastdate}.gz ] ; then
scp /usr/local/tomcat0-tata-gw52/logs/catalina.out-${pastdate}.gz
root at 172.20.0.20:/somefolder/
rm -f /usr/local/tomcat0-tata-gw52/logs/catalina.out-${pastdate}.gz
fi
endscript
}

Please suggest. Am i missing something.

Thanks,

Kaushal




More information about the ubuntu-users mailing list