Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software
User Name
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.


  Search this Thread
Old 06-22-2009, 02:58 AM   #1
Registered: Nov 2004
Distribution: Fedora Core 2
Posts: 330

Rep: Reputation: 30
logrotate doesnt not rotate properly

Dear friends,

I have the following logrotate configuration in /etc/logrotate.d/maillog

/var/log/maillog {
rotate 5

, so i did a debug run with the following command:

1st rotate) logrotate -f -s -d /etc/logrotate.d/maillog

The first rotate works fine with the following results in /var/log:
maillog.1 (note: original maillog is missing)

2nd rotate) logrotate -f -s -d /etc/logrotate.d/maillog

The error says:
error: stat of /var/log/maillog failed: No such file or directory

apparently because the original maillog file has been replaced with maillog.1.

but based on the
during a rotate, the original maillog will be replaced by maillog.1 by the original does not remove.

so my understanding the content of /var/log folder should be:
before rotate: maillog
first rotate: maillog maillog.1
2nd rotate: maillog maillog.2 maillog.3
3rd rotate maillog maillog.2 maillog.3 maillog.4
and on and on.....till rotate no 5 it gets roll over again.

However my configuration above now is working incrrectly as below:
before rotate: maillog
first rotate: maillog.1
2nd rotate: failed because "error: stat of /var/log/maillog failed: No such file or directory"

anyone knows what went wrong in my configuration?
All i want to achieve is a rotation on a daily basis, so that i have each log file containning only 1 day of log records, day by day, easy for analysis. Rotate for 7 days then replace again.
I couldnt achive it because of the above problem, hope anyone can point out my mistake.

Old 06-22-2009, 03:56 AM   #2
Senior Member
Registered: May 2004
Location: Leipzig/Germany
Distribution: Arch
Posts: 1,687

Rep: Reputation: 54
There is probably nothing wrong.
The log-files are created when written to.
You removed the logfile by rotating it.
If nothing was written to the maillog before you tried to rotate it again - it is not there.

man logrotate

There are options like:
postrotate - which can take care of i.e. reloading the logger after the logfiles have been rotated.
My (the default) config for syslog-ng looks like this:
/var/log/messages {
        /etc/init.d/syslog-ng reload > /dev/null 2>&1 || true

Last edited by jomen; 06-22-2009 at 04:01 AM.
Old 06-22-2009, 04:26 AM   #3
Registered: Jun 2009
Location: INDIA
Distribution: RHEL-5
Posts: 174
Blog Entries: 3

Rep: Reputation: 38
yea thats true i hope its work.


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
Logrotate doesn't rotate logs kenneho Linux - Desktop 5 03-23-2010 12:13 PM
Logrotate: Rotate Apache logs, but never delete kenneho Linux - Newbie 2 10-23-2008 06:58 AM
'logrotate' does not rotate news logfile andrew.46 Slackware 2 01-28-2008 03:43 PM
How to get logrotate to only rotate files 2 days old. yoda_mon Linux - Software 1 05-18-2006 08:55 PM
Squid - rotate doesnt work Wormi Linux - Networking 1 06-04-2005 04:06 PM

All times are GMT -5. The time now is 11:48 PM.

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