1751790 Members
5012 Online
108781 Solutions
New Discussion юеВ

Re: logrotate

 
SOLVED
Go to solution
chakri
Occasional Contributor

logrotate

Hi,

i would like to logrotate system logs /var/log/* every day and delete 7 days older logs.

this is not happening in my linux machine. logs are getting rotated every day but 7 days older logs are not getting deleted.

could you please let me know what could be the issue.

logrotate.conf
--------
# see "man logrotate" for details
# rotate log files weekly
daily

# keep 7 days worth of backlogs
rotate 7

# create new (empty) log files after rotating old ones
create

# Rotate log if it is bigger than SIZE
#size=100M

# uncomment this if you want your log files compressed
#compress

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp, or btmp -- we'll rotate them here
/var/log/wtmp {
monthly
create 0664 root utmp
rotate 1
}

# system-specific logs may be also be configured here.
/var/log/kern.log /var/log/debug /var/log/auth.log /var/log/daemon.log /var/log/messages /var/log/user.log /var/log/mail.err /var/log/mail.info /var/log/mail.log /var/log/mail.warn /var/log/uucp.log /var/log/faillog /var/log/dmesg {
daily
create 0640 root logadm
postrotate
/etc/init.d/syslog restart
endscript
rotate 7
}

5 REPLIES 5
Ivan Ferreira
Honored Contributor

Re: logrotate

Change the "dayly" option to "weekly".

ogrotate.conf
--------
# see "man logrotate" for details
# rotate log files weekly
# daily
weekly
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
chakri
Occasional Contributor

Re: logrotate

could some one please explain me what does rotate will do,, doest it rotate logs so many times daily/weekly or it will delete logs after days???

also in my problem how does changing to weekly will help?
Ivan Ferreira
Honored Contributor
Solution

Re: logrotate

>>> could some one please explain me what does rotate will do,, doest it rotate logs so many times daily/weekly or it will delete logs after days???

Log rotate will rotate the files at the interval specified. If you specify "daily" and "rotate 6", you will have 6 copies of your log files rotated daily, that is, the 6 most recent, or 6 days.

If you specify weekly, and rotate 1, for example, you will have one log file containing logs for the entire week.

Probably I understand wrong your first post. How many logs do you have in your log directory with "daily" and "rotate 7" options?

Have you manually added the section under:
# system-specific logs may be also be configured here.

This should be not neccesary as in /etc/logrotate.d, which is included in the configuration file, you have the syslog configuration file which rotates system logs.

You can force a rotation with:

logrotate -f /etc/logrotate.conf

Check also /var/lib/logrotate.status
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
chakri
Occasional Contributor

Re: logrotate

thank you,

my configuration was correct but while testing i was not using -f option.

thanks again..

Re: logrotate

Hi,

I'm a new guy to linux, and trying to create a log rotation for one of my logs, can you tell me how to do this... I have tried so many site with their comments..

Location of my file : /usr/local/lbx/xl_wat/wasp65/bin/output.log

please help me...