<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://aznot.com/index.php?action=history&amp;feed=atom&amp;title=Linux%2Flogrotate</id>
	<title>Linux/logrotate - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://aznot.com/index.php?action=history&amp;feed=atom&amp;title=Linux%2Flogrotate"/>
	<link rel="alternate" type="text/html" href="https://aznot.com/index.php?title=Linux/logrotate&amp;action=history"/>
	<updated>2026-05-09T02:43:14Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://aznot.com/index.php?title=Linux/logrotate&amp;diff=1177&amp;oldid=prev</id>
		<title>Kenneth: /* logrotate */</title>
		<link rel="alternate" type="text/html" href="https://aznot.com/index.php?title=Linux/logrotate&amp;diff=1177&amp;oldid=prev"/>
		<updated>2014-10-09T01:35:10Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;logrotate&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== logrotate ==&lt;br /&gt;
&lt;br /&gt;
 logrotate - rotates, compresses, and mails system logs&lt;br /&gt;
&lt;br /&gt;
Installation:&lt;br /&gt;
 yum install logrotate vixie-cron crontab&lt;br /&gt;
 service crond restart&lt;br /&gt;
&lt;br /&gt;
Configuration files are here:&lt;br /&gt;
 /etc/cron.daily/logrotate&lt;br /&gt;
 /etc/logrotate.conf&lt;br /&gt;
 /etc/logrotate.d&lt;br /&gt;
&lt;br /&gt;
Last rotate status is kept here:&lt;br /&gt;
 /var/lib/logrotate.status&lt;br /&gt;
&lt;br /&gt;
Kick off a rotate config:&lt;br /&gt;
 logrotate -v /etc/logrotate.d/httpd&lt;br /&gt;
&lt;br /&gt;
== copytruncate ==&lt;br /&gt;
&lt;br /&gt;
&amp;quot;To avoid the reload, instead of moving the file, you can copy it and empty the old file. That way apache can keep writing to the same filehandle. You do this by adding the option &amp;quot;copytruncate&amp;quot; to the logrotate config file, like this:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/apache/*log {&lt;br /&gt;
    copytruncate&lt;br /&gt;
    compress&lt;br /&gt;
    dateext&lt;br /&gt;
    rotate 365&lt;br /&gt;
    size=+300M&lt;br /&gt;
    olddir /log/old/apache&lt;br /&gt;
    notifempty&lt;br /&gt;
    missingok&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
References:&lt;br /&gt;
* logrotate - How to avoid apache reload when rotating logs? - Unix &amp;amp; Linux Stack Exchange - http://unix.stackexchange.com/questions/47688/how-to-avoid-apache-reload-when-rotating-logs&lt;br /&gt;
&lt;br /&gt;
== CentOS HTTP Example ==&lt;br /&gt;
&lt;br /&gt;
Suggested add:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/var/log/httpd/*log {&lt;br /&gt;
    size 100M&lt;br /&gt;
    compress&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ln -s /etc/cron.daily/logrotate /etc/cron.hourly/logrotate&lt;br /&gt;
&lt;br /&gt;
/etc/logrotate.d/httpd&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/var/log/httpd/*log {&lt;br /&gt;
    missingok&lt;br /&gt;
    notifempty&lt;br /&gt;
    sharedscripts&lt;br /&gt;
    delaycompress&lt;br /&gt;
    postrotate&lt;br /&gt;
        /sbin/service httpd reload &amp;gt; /dev/null 2&amp;gt;/dev/null || true&lt;br /&gt;
    endscript&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/etc/logrotate.conf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# see &amp;quot;man logrotate&amp;quot; for details&lt;br /&gt;
# rotate log files weekly&lt;br /&gt;
weekly&lt;br /&gt;
&lt;br /&gt;
# keep 4 weeks worth of backlogs&lt;br /&gt;
rotate 4&lt;br /&gt;
&lt;br /&gt;
# create new (empty) log files after rotating old ones&lt;br /&gt;
create&lt;br /&gt;
&lt;br /&gt;
# use date as a suffix of the rotated file&lt;br /&gt;
dateext&lt;br /&gt;
&lt;br /&gt;
# uncomment this if you want your log files compressed&lt;br /&gt;
#compress&lt;br /&gt;
&lt;br /&gt;
# RPM packages drop log rotation information into this directory&lt;br /&gt;
include /etc/logrotate.d&lt;br /&gt;
&lt;br /&gt;
# no packages own wtmp and btmp -- we&amp;#039;ll rotate them here&lt;br /&gt;
/var/log/wtmp {&lt;br /&gt;
    monthly&lt;br /&gt;
    create 0664 root utmp&lt;br /&gt;
        minsize 1M&lt;br /&gt;
    rotate 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/var/log/btmp {&lt;br /&gt;
    missingok&lt;br /&gt;
    monthly&lt;br /&gt;
    create 0600 root utmp&lt;br /&gt;
    rotate 1&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# system-specific logs may be also be configured here.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/etc/cron.daily/logrotate&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/usr/sbin/logrotate /etc/logrotate.conf &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;
EXITVALUE=$?&lt;br /&gt;
if [ $EXITVALUE != 0 ]; then&lt;br /&gt;
    /usr/bin/logger -t logrotate &amp;quot;ALERT exited abnormally with [$EXITVALUE]&amp;quot;&lt;br /&gt;
fi&lt;br /&gt;
exit 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kenneth</name></author>
	</entry>
</feed>