LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-30-2006, 07:17 AM   #1
keyF
Member
 
Registered: Jan 2006
Location: Moscow
Distribution: Debian, RHEL, FreeBSD, CentOS
Posts: 38

Rep: Reputation: 15
Problem rotating Postfix logs


Hello,

I tried to search thru the forum and google about my problem, but didn't found anything..

My system: Debian 3.1, Postfix 2.1.5.

Here is the problem: when my mail logs get rotated postfix don't start to write to new files, and continue to write into rotated log files instead.

My /etc/syslog.conf:
Code:
...
mail.*                          -/var/log/mail.log
...
mail.info                       -/var/log/mail.info
mail.warn                       -/var/log/mail.warn
mail.err                        /var/log/mail.err
My /etc/logrotate.d/postfix-logs:
Code:
/var/log/mail.info /var/log/mail.err /var/log/mail.log /var/log/mail.warn  {
#        daily
        size=1k #for testing
        rotate 10
        compress
        delaycompress
        notifempty
        create 640 root root
}
Here is the /var/log/ listing before logrotate:
Code:
24:~# ls /var/log/mail.* -lh
-rw-r-----  1 root root 132K Aug 29 22:25 /var/log/mail.err
-rw-r-----  1 root root 3.0M Aug 30 08:09 /var/log/mail.info
-rw-r-----  1 root root 1.9M Aug 30 08:09 /var/log/mail.log
-rw-r-----  1 root root 4.1M Aug 30 08:05 /var/log/mail.warn
then I run
Code:
/usr/sbin/logrotate /etc/logrotate.d/postfix-logs
and logortate renames my log files to mail.*.1 and creates new logs mail.info, mail.err, etc.
BUT those files are zero length, and rotated files (mail.info.1 for example) are growing because postfix writes to them.

So, what should I do to let postfix know about new files?
"postfix restart" and "/etc/init.d/syslogd restart" does not help.

please advice ;(
 
Old 08-30-2006, 07:25 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
i don't have massive amounts of experience here, but i'm fairly sure you need to HPU the syslogd process. one of my default logrotate scripts looks like this:

Code:
/var/log/messages /var/log/secure /var/log/maillog /var/log/spooler /var/log/boot.log /var/log/cron {
    sharedscripts
    postrotate
        /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
    endscript
}
so once the rotate is actually done the kill command is used to send a HUP, which will close and reopen all files, so the existing filehandle which whilst open is oblivious to filename changes closes and reopenss the right file names, i.e. the new blank file is now in use.

btw, syslog-ng is so so much nicer that syslogd and deals with it's own rotation issues so these things don't matter.
 
Old 08-30-2006, 07:42 AM   #3
keyF
Member
 
Registered: Jan 2006
Location: Moscow
Distribution: Debian, RHEL, FreeBSD, CentOS
Posts: 38

Original Poster
Rep: Reputation: 15
YES!
now it works right thank you many times!

but it it strange, because i've tried
Code:
/etc/init.d/syslogd stop
/etc/init.d/syslogd start
before and it does not solved problem. i guess that full stop includes actions taken on HUP signal..
but thank you anyway
 
Old 08-30-2006, 07:56 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
yeah i would have thought that'd do it too...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Emails rejected by Postfix is not showing in the logs andrewthk Linux - Networking 0 01-24-2006 12:48 AM
Mail logs + Postfix + SQL + etc... Sapient Linux - Software 1 01-06-2006 08:08 PM
Postfix Logs dawidson Linux - Newbie 1 12-28-2005 03:13 PM
Postfix send, but will not receive (or display in logs) jules_fraser Linux - Networking 0 01-01-2005 07:46 PM
Domain Routing to Postfix from Sendmail = Wrong IP information in Mail Logs! dholingw Linux - Networking 2 05-20-2004 10:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:22 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