LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-30-2011, 02:51 AM   #1
Skillz
Member
 
Registered: Sep 2007
Posts: 252

Rep: Reputation: 32
Log rotation..


So it seems that my server isn't rotating logs like it should. I can confirm this as the logs ending with .[x] where [x] is a number usually 1 - 4 are all months old according to the time stamp and the main log file without any .[x] appended to it is rather large. I only noticed this because I have my messages log emailed to me daily using a script
Code:
less /var/log/messages | grep "$(date --date="yesterday" '+%b %e')" | mail -s "title of email" my@email.address
However, since I installed this script a year ago, I'm starting to see logs from last August show up in today's emails; so I began looking.

I know logrotate is what handles log rotation, but how can I check to see why it's stopped working for whatever reason?

I ran this command, as I figured it would shed some light on it but it doesn't seem to be helping.

/usr/sbin/logrotate -vf /etc/logrotate.conf

This is the output of the above command.
Code:
reading config file /etc/logrotate.conf
including /etc/logrotate.d
reading config file acpid
reading config info for /var/log/acpid
reading config file conman
reading config info for /var/log/conman/*
olddir is now /var/log/conman.old/
reading config file cups
reading config info for /var/log/cups/*_log
reading config file exim
reading config info for /var/log/exim_mainlog
reading config info for /var/log/exim_paniclog
reading config info for /var/log/exim_rejectlog
reading config file httpd
reading config info for /var/log/httpd/*log
reading config file mgetty
reading config info for /var/log/mgetty.log.tty[^.] /var/log/mgetty.log.tty[^.][^.] /var/log/mgetty.log.tty[^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.][^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.][^.][^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.][^.][^.][^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.][^.][^.][^.][^.][^.][^.] /var/log/mgetty.log.unknown /var/log/mgetty.callback
reading config file mysql
reading config info for /var/lib/mysql/mysqld.log
reading config file named
reading config info for /var/log/named.log
reading config file ppp
reading config info for /var/log/ppp/connect-errors
reading config file psacct
reading config info for /var/account/pacct
reading config file rpm
reading config info for /var/log/rpmpkgs
reading config file sa-update
reading config info for /var/log/sa-update.log
reading config file samba
reading config info for /var/log/samba/*.log
reading config file setroubleshoot
reading config info for /var/log/setroubleshoot/*.log
reading config file snort
error: error accessing /var/log/snort/*: No such file or directory
error: snort:4 glob failed for /var/log/snort/*/*log
Not sure what most of that means, but whatever. Where do I start?
 
Old 08-30-2011, 03:13 AM   #2
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by Skillz View Post
So it seems that my server isn't rotating logs like it should. I can confirm this as the logs ending with .[x] where [x] is a number usually 1 - 4 are all months old according to the time stamp and the main log file without any .[x] appended to it is rather large. I only noticed this because I have my messages log emailed to me daily using a script
Code:
less /var/log/messages | grep "$(date --date="yesterday" '+%b %e')" | mail -s "title of email" my@email.address
However, since I installed this script a year ago, I'm starting to see logs from last August show up in today's emails; so I began looking.

I know logrotate is what handles log rotation, but how can I check to see why it's stopped working for whatever reason?

I ran this command, as I figured it would shed some light on it but it doesn't seem to be helping.

/usr/sbin/logrotate -vf /etc/logrotate.conf

This is the output of the above command.
Code:
reading config file /etc/logrotate.conf
including /etc/logrotate.d
reading config file acpid
reading config info for /var/log/acpid
reading config file conman
reading config info for /var/log/conman/*
olddir is now /var/log/conman.old/
reading config file cups
reading config info for /var/log/cups/*_log
reading config file exim
reading config info for /var/log/exim_mainlog
reading config info for /var/log/exim_paniclog
reading config info for /var/log/exim_rejectlog
reading config file httpd
reading config info for /var/log/httpd/*log
reading config file mgetty
reading config info for /var/log/mgetty.log.tty[^.] /var/log/mgetty.log.tty[^.][^.] /var/log/mgetty.log.tty[^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.][^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.][^.][^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.][^.][^.][^.][^.][^.] /var/log/mgetty.log.tty[^.][^.][^.][^.][^.][^.][^.][^.][^.][^.] /var/log/mgetty.log.unknown /var/log/mgetty.callback
reading config file mysql
reading config info for /var/lib/mysql/mysqld.log
reading config file named
reading config info for /var/log/named.log
reading config file ppp
reading config info for /var/log/ppp/connect-errors
reading config file psacct
reading config info for /var/account/pacct
reading config file rpm
reading config info for /var/log/rpmpkgs
reading config file sa-update
reading config info for /var/log/sa-update.log
reading config file samba
reading config info for /var/log/samba/*.log
reading config file setroubleshoot
reading config info for /var/log/setroubleshoot/*.log
reading config file snort
error: error accessing /var/log/snort/*: No such file or directory
error: snort:4 glob failed for /var/log/snort/*/*log
Not sure what most of that means, but whatever. Where do I start?


Best place to start is by running in debug mode

Code:
logrotate -v -d /path/to/logrotate.conf
from what you have pasted, looks like a config problem with the snort log directory, and so the whole process is failing.
Run again in debug mode and paste the output...or fix the error on line 4 of the snort config file.

Code:
error: error accessing /var/log/snort/*: No such file or directory
error: snort:4 glob failed for /var/log/snort/*/*log
[/code]
 
Old 08-30-2011, 03:31 AM   #3
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
IIRC if in the logrotate process one of the logrotates fail (that is a file to rotate does not exist) all following commands are not executed. You would have this when you stopp logging with a certain program and delete old log files. That is a bit unexpected, as one would not consider that an error. Still logrotate does and ceases execution.

jlinkels
 
Old 08-30-2011, 11:19 PM   #4
Skillz
Member
 
Registered: Sep 2007
Posts: 252

Original Poster
Rep: Reputation: 32
Well I just deleted the snort config file for right now.

When I run it in debug mode, too much information is passing through the screen at once.

Tried running

logrotate -v -d /path/to/logrotate.conf | less

Still wouldn't stop so I could see everything.

Also tried

logrotate -v -d /path/to/logrotate.conf > output.txt

But it was just a blank document it created.
 
Old 08-30-2011, 11:25 PM   #5
Skillz
Member
 
Registered: Sep 2007
Posts: 252

Original Poster
Rep: Reputation: 32
Well I think log rotation has resumed. I will keep an eye on it for the next few days, then see about getting snort back in the mix. For the record, here is the snort config file.

Code:
# /etc/logrotate.d/snort
# $Id$

/var/log/snort/alert /var/log/snort/*log /var/log/snort/*/alert /var/log/snort/*/*log  {
    daily
    rotate 7
    missingok
    compress
    sharedscripts
    postrotate
        /etc/init.d/snortd restart 1>/dev/null || true
    endscript
}
 
Old 08-30-2011, 11:29 PM   #6
Skillz
Member
 
Registered: Sep 2007
Posts: 252

Original Poster
Rep: Reputation: 32
Actually, think I see the problem.

/var/log/snort/alert (E)xists

/var/log/snort/*log (No files end in log)

/var/log/snort/*/alert (their are no directories in /snort)

/var/log/snort/*/*log (their are no directories in /snort)

So I think if I change it to

/var/log/snort/*log* (Some files do have log as an extension, but behind it is a series of numbers [guessing its a time stamp])
/var/log/snort/alert* (This should gather all the files that are alert.{series of numbers})
delete this bit of code, as it wont catch anything that the /var/log/snort/*log* doesn't already catch.

Maybe?
 
Old 08-31-2011, 01:05 PM   #7
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
I think you are creating problems with using *log* as files will get rotated and re-rotated. Check the man page (there is a paragraph on this) and refer to the olddir directive.

You redirection into a file to trace the error created a blank file because these error messages appear on stderr, not stdout.

Try: logrotate -v -d /path/to/logrotate.conf >> output.txt 2>&1

jlinkels
 
Old 09-03-2011, 04:49 PM   #8
Skillz
Member
 
Registered: Sep 2007
Posts: 252

Original Poster
Rep: Reputation: 32
Everything is working like it should, thanks everyone.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change Debian log rotation of syslog and daemon.log onmountain Linux - Newbie 2 07-31-2008 02:27 AM
Log Rotation for snort log does not seem to be working CentOS4.5 JasonKretzer Linux - Security 3 06-25-2007 12:25 PM
Log Rotation using Logrotate keysorsoze Linux - General 4 04-13-2007 02:51 PM
Webalizer With Log Rotation dmedici Linux - Software 0 08-17-2004 09:06 AM
manual log rotation will103 Linux - Newbie 2 04-20-2004 02:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration