Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to rotate my maillog, but I want to make sure the newly rotated log contains the last 2M lines from the previous log:

    # write the last 2M lines to a new log
    tail -n 2000000 /var/log/maillog > /var/log/maillog.new

    # move the existing log to datestamped backup
    datestamp=`date "+%Y%m%d"`
    mv /var/log/maillog /var/log/maillog.$datestamp

    # move the new log to normal log
    mv /var/log/maillog.new /var/log/maillog

    # tell sendmail to reload
    killall -HUP sendmail

This all works, except for the fact that sendmail continues to write to the backup log file "maillog.yyyymmdd" instead of the proper "maillog"!

What is the correct way to do this without having to stop sendmail first, rotate, then start again?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

Usually maillog written by syslogd, not by sendmail itself, so you should send SIGHUP to syslogd

share|improve this answer
    
Thanks - that did it. –  jemminger Feb 6 '11 at 20:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.