Re: rotate logs when they reach a certain size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2003-10-24 at 12:13, Genti Hila wrote:
>  The cron jobs and logrotate seem to manipulate logs in a time basis, but i
> was trying to figure out a way how to make the logs delete when they get big
> to a certain size and not in a daily or weekly or whatever time basis.
> 
> Does anybody know how to do that in Redhat 9 ?

Put something like this in /etc/logrotate.conf 

# Newslog
/var/log/newslog  {
    missingok
    compress
    size 2M
    rotate 3
    create 0660 root news
}

or the individual files such as

[root@www root]# cat /etc/logrotate.d/amavis.log
# Restart amavisd when rotating amavis.log
/var/amavis/amavis.log {
    rotate 4
    compress
    size 4M
    postrotate
        /sbin/service amavisd restart 2> /dev/null || true
    endscript
}

I rotate both on time and size. This forces a rotation monthly:

[root@www root]# cat /etc/cron.monthly/logrotate
#!/bin/sh
 
/usr/sbin/logrotate -f /etc/logrotate.conf

This checks it daily for size:

[root@www root]# cat /etc/cron.daily/logrotate
#!/bin/sh
 
/usr/sbin/logrotate /etc/logrotate.conf

The size overrides the date unless the -f option is used. Hence, I always
rotate at the first of the month or whenever the size reaches the set size.

HTHs.


-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux