[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: logrotate strangeness (nothing worrisome however)



Hi Jim,

First of all, sorry for my poor English.

On Fri, 18 May 2007 19:30:30 -0400
Jim Popovitch <yahoo@jimpop.com> wrote:

> I've noticed something strange with logrotate, looking for insight and
> explanation if you have one.
> 
> ls -1 /var/log/syslog*  shows:
> 
> 	/var/log/syslog
> 	/var/log/syslog.0
> 	/var/log/syslog.1.gz
> 	/var/log/syslog.2.gz
> 	/var/log/syslog.3.gz
> 	/var/log/syslog.4.gz
> 	/var/log/syslog.5.gz
> 	/var/log/syslog.6.gz
> 
> which tells me that delaycompress is delaying the gzipping of .0 until
> the next rotation.  This is nice and works as expected.

Probably it is a misapprehension that you think that rotation of the
syslog is carried out by logrotate command.

Rotation of the syslog is carried out by the savelog command in the two
shell scripts "/etc/cron.daily/sysklogd" and "/etc/cron.weekly/sysklogd". 
(Please see the contents of those shell scripts for details.)

And it seems to be the work as expected that the savelog command (it's
a shell script in fact) starts the rotation of specified file from .0.
(cf. savelog(8))


> However, ls -1 /var/log/apache2/access* shows:
> 
> 	/var/log/apache2/access.log
> 	/var/log/apache2/access.log.1
> 	/var/log/apache2/access.log.2.gz
> 	/var/log/apache2/access.log.3.gz
> 	/var/log/apache2/access.log.4.gz
> 	/var/log/apache2/access.log.5.gz
> 
> /etc/logrotate.d/apache contains this:
> 
> 	---------------------
> 	/var/log/apache2/*.log {
> 	        weekly
> 	        missingok
> 	        rotate 6
> 	        compress
> 	        delaycompress
> 	        notifempty
> 	        create 640 root adm
> 	        sharedscripts
> 	        postrotate
> 	                if [ -f /var/run/apache2.pid ]; then
> 	                        /etc/init.d/apache2 restart > /dev/null
> 	                fi
> 	        endscript
> 	}
> 	---------------------
> 
> Why do apache logs rotate from blah to blah.1 whereas syslog rotates
> from syslog to syslog.0?

In above configuration file, it seems to be the work as expected that
the logrotate command starts the rotation of specified file from .1.

If you add "start 0" line to the /etc/logrotate.d/apache file, I think
that the logrotate command starts rotation from .0.
(cf. logrotate(8))

Moreover, you can see how the logrotate command works by the specified
configuration file in detail by executing the following command line:

  logrotate -fv /etc/logrotate.d/apache

Thanks,

--
Yukio Shiiya <shiiya @ sky.email.ne.jp>



Reply to: