LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Logs are not rotated (https://www.linuxquestions.org/questions/slackware-14/logs-are-not-rotated-274124/)

BroX 01-05-2005 08:14 AM

Logs are not rotated
 
Hey all,

Running Slack 10, kernel 2.4.28 on my laptop. I noticed that my logs are not rotating. /var/log/messages and /var/log/syslog are over 1Mb now, and the starting date is when I did a reinstall last year November.
After reading several posts, I checked the following and couldn't find anything wrong:

* No logs have passed the 2G limit, which would stop all logging.
Code:

root@leon-fyg:/home/leon# ps ax | grep syslogd
  69 ?        Ss    0:00 /usr/sbin/syslogd
 1873 pts/1    S+    0:00 grep syslogd
root@leon-fyg:/home/leon#

Code:

cat /var/lib/logrotate/status
logrotate state -- version 2
"/var/log/cron" 2005-1-4
"/var/log/debug" 2005-1-4
"/var/log/maillog" 2005-1-4
"/var/log/messages" 2005-1-4
"/var/log/secure" 2005-1-4
"/var/log/spooler" 2005-1-4
"/var/log/syslog" 2005-1-4
"/var/log/wtmp" 2005-1-4

So all logs were 'attempted' to be rotated
When I start logrotate from console I get
Code:

root@leon-fyg:/home/leon# logrotate -d /etc/logrotate.conf
reading config file /etc/logrotate.conf
including /etc/logrotate.d
reading config file syslog
reading config info for /var/log/cron /var/log/debug /var/log/maillog /var/log/m
essages /var/log/secure /var/log/spooler /var/log/syslog
reading config info for /var/log/wtmp

Handling 2 logs

rotating pattern: /var/log/cron /var/log/debug /var/log/maillog /var/log/message
s /var/log/secure /var/log/spooler /var/log/syslog  weekly (4 rotations)
empty log files are rotated, old logs are removed
considering log /var/log/cron
  log does not need rotating
considering log /var/log/debug
  log does not need rotating
considering log /var/log/maillog
  log does not need rotating
considering log /var/log/messages
  log does not need rotating
considering log /var/log/secure
  log does not need rotating
considering log /var/log/spooler
  log does not need rotating
considering log /var/log/syslog
  log does not need rotating
not running shared postrotate script, since no logs were rotated

rotating pattern: /var/log/wtmp  monthly (1 rotations)
empty log files are rotated, old logs are removed
considering log /var/log/wtmp
  log does not need rotating
root@leon-fyg:/home/leon#

Code:

root@leon-fyg:/home/leon# less /etc/logrotate.conf
# /etc/logrotate.conf
#
# logrotate is designed to ease administration of systems that generate large
# numbers of log files.  It allows automatic rotation, compression, removal, and
# mailing of log files.  Each log file may be handled daily, weekly, monthly, or
# when it grows too large.
#
# logrotate is normally run daily from root's crontab.
#
# For more details, see "man logrotate".

# rotate log files weekly:
weekly

# keep 4 weeks worth of backlogs:
rotate 4

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

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

# some packages install log rotation information in this directory:
include /etc/logrotate.d

# Rotate /var/log/wtmp:
/var/log/wtmp {
    monthly
    create 0664 root utmp
    rotate 1
}

# Note that /var/log/lastlog is not rotated.  This is intentional, and it should
# not be.  The lastlog file is a database, and is also a sparse file that takes
# up much less space on the drive than it appears.

# system-specific logs may be also be configured below:

root@leon-fyg:/home/leon#

Code:

root@leon-fyg:/home/leon# cat /etc/logrotate.d/syslog
/var/log/cron /var/log/debug /var/log/maillog /var/log/messages /var/log/secure /var/log/spooler /var/log/syslog {
    sharedscripts
    postrotate
        /bin/kill -HUP `cat /var/run/syslogd.pid 2>/dev/null` 2>/dev/null || true
    endscript
}
root@leon-fyg:/home/leon#

Sorry for the long post, but hopefully I've provided enough configs etc for someone to detect why the logs are not rotated by cron.daily.

Cheers, Leon.

Cedrik 01-05-2005 01:55 PM

Why did you use the -d switch for logrotate ?

man logrotate :

-d Turns on debug mode and implies -v. In debug mode,
no changes will be made to the logs or to the
logrotate state file.

BroX 01-06-2005 05:17 AM

Quote:

Originally posted by Cedrik
Why did you use the -d switch for logrotate ?
To be honest, I just copied that from another thread.
When I leave the -d, the logs aren't rotated either:
Code:

bash-3.00# logrotate -v /etc/logrotate.conf
reading config file /etc/logrotate.conf
including /etc/logrotate.d
reading config file syslog
reading config info for /var/log/cron /var/log/debug /var/log/maillog /var/log/messages /var/log/secure /var/log/spooler /var/log/syslog
reading config info for /var/log/wtmp

Handling 2 logs

rotating pattern: /var/log/cron /var/log/debug /var/log/maillog /var/log/messages /var/log/secure /var/log/spooler /var/log/syslog  weekly (4 rotations)
empty log files are rotated, old logs are removed
considering log /var/log/cron
  log does not need rotating
considering log /var/log/debug
  log does not need rotating
considering log /var/log/maillog
  log does not need rotating
considering log /var/log/messages
  log does not need rotating
considering log /var/log/secure
  log does not need rotating
considering log /var/log/spooler
  log does not need rotating
considering log /var/log/syslog
  log does not need rotating
not running shared postrotate script, since no logs were rotated

rotating pattern: /var/log/wtmp  monthly (1 rotations)
empty log files are rotated, old logs are removed
considering log /var/log/wtmp
  log does not need rotating
bash-3.00#

What am I missing here???

Cedrik 01-06-2005 07:06 AM

could you post the output of :
ls -al /var/log/messages*

BroX 01-06-2005 07:26 AM

Quote:

Originally posted by Cedrik
could you post the output of :
ls -al /var/log/messages*

leon@leon-fyg:~$ la /var/log/messages*
-rw-r----- 1 root root 1.3M Jan 6 15:27 /var/log/messages
leon@leon-fyg:~$

Cedrik 01-06-2005 07:34 AM

did you try the -f option ?

logrotate -f -v /etc/logrotate.conf

BroX 01-06-2005 07:48 AM

Quote:

Originally posted by Cedrik
did you try the -f option ?

logrotate -f -v /etc/logrotate.conf

YES! Forcing it does the job. But why doesn't it work normally...
Maybe after this one time forced logrotate it will do it automatically during future cron jobs?
If not, would it be a bad idea to add the -f to the cron.daily logrotate script?

Thanks a lot!

Cheers, Leon.

Cedrik 01-06-2005 08:02 AM

I think logrotate use the infos provided by /var/lib/logrotate/status to know if rotate logs are needed, so I would
think that if you let it be, it will rotate the logs after a period of time

BroX 01-06-2005 08:19 AM

Cedrik,

thanks for your help!

Cheers, Leon.

Hans Zarkoff 01-08-2005 01:12 AM

Wow, I must have been sleeping for the last 10 years! Here's what I've been doing for a log rotation. No one asked me for this, but maybe it'll help someone do something.

#!/bin/bash

tmp="/var/log/messages".`date +"%m%d%H%M%Y"`
/bin/cp /var/log/messages $tmp
/bin/cat /dev/null > /var/log/messages

BroX 01-11-2005 08:41 AM

Quote:

Originally posted by Cedrik
I think logrotate use the infos provided by /var/lib/logrotate/status to know if rotate logs are needed, so I would think that if you let it be, it will rotate the logs after a period of time
For completeness of the thread: yes indeed cron now rotates the logs automatically! :)

Cheers, Leon.

fschroder 06-03-2009 06:49 PM

Although very old this msg helped me, so I thought about contributing.

Quote:

I think logrotate use the infos provided by /var/lib/logrotate/status to know if rotate logs are needed, so I would think that if you let it be, it will rotate the logs after a period of time
It only worked with the -f option for me too, until I tweaked the info stored in /var/lib/logrotate.status. I had to set the log date to a previous date for it to start working.


All times are GMT -5. The time now is 11:13 AM.