logrotate

Amedee Van Gasse (ub) amedee-ubuntu at amedee.be
Thu Mar 4 10:23:34 UTC 2010


On Thu, March 4, 2010 10:43, Ian Coetzee 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.

There is nothing wrong with putting your "find" script in the postrotate
section of logrotate, so that you don't need an extra cronjob. That's what
I meant.

Just a thought. Log files get renamed by logrotate like this:

mail.log
mail.log.1
mail.log.2.gz
mail.log.3.gz
...

Suppose you logrotate every week, then mail.log.3.gz will be older than 15
days and it is candidate to be scp'd or rsync'd.
Next week there will be a *new* mail.log.3.gz, which was the old
mail.log.2.gz. When you rsync that, it will overwrite the old
mail.log.3.gz on the remote host, unless you have taken precautions there.

A solution could be to also logrotate the backup logfiles on the remote host.





More information about the ubuntu-users mailing list