glfs/general/sysutils/logrotate.xml
Fernando de Oliveira bc5778fd6d svn propset svn:keywords 'Date LastChangedBy' newt.xml libndp.xml logrotate.xml.
git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@13347 af4574ff-66df-0310-9fd7-8a98e5e911e0
2014-07-05 22:06:43 +00:00

250 lines
6.7 KiB
XML

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % general-entities SYSTEM "../../general.ent">
%general-entities;
<!ENTITY logrotate-download-http "http://fedorahosted.org/releases/l/o/logrotate/logrotate-&logrotate-version;.tar.gz">
<!ENTITY logrotate-download-ftp " ">
<!ENTITY logrotate-md5sum "99e08503ef24c3e2e3ff74cc5f3be213">
<!ENTITY logrotate-size "64 KB">
<!ENTITY logrotate-buildsize "1.3 MB">
<!ENTITY logrotate-time "less than 0.1 SBU">
]>
<sect1 id="logrotate" xreflabel="logrotate-&logrotate-version;">
<?dbhtml filename="logrotate.html"?>
<sect1info>
<othername>$LastChangedBy$</othername>
<date>$Date$</date>
</sect1info>
<title>Logrotate-&logrotate-version;</title>
<indexterm zone="logrotate">
<primary sortas="a-logrotate">logrotate</primary>
</indexterm>
<sect2 role="package">
<title>Introduction to Logrotate</title>
<para>
The <application>logrotate</application> package allows automatic rotation,
compression, removal, and mailing of log files.
</para>
&lfs75_checked;
<bridgehead renderas="sect3">Package Information</bridgehead>
<itemizedlist spacing="compact">
<listitem>
<para>
Download (HTTP): <ulink url="&logrotate-download-http;"/>
</para>
</listitem>
<listitem>
<para>
Download (FTP): <ulink url="&logrotate-download-ftp;"/>
</para>
</listitem>
<listitem>
<para>
Download MD5 sum: &logrotate-md5sum;
</para>
</listitem>
<listitem>
<para>
Download size: &logrotate-size;
</para>
</listitem>
<listitem>
<para>
Estimated disk space required: &logrotate-buildsize;
</para>
</listitem>
<listitem>
<para>
Estimated build time: &logrotate-time;
</para>
</listitem>
</itemizedlist>
<bridgehead renderas="sect3">Logrotate Dependencies</bridgehead>
<bridgehead renderas="sect4">Required</bridgehead>
<para role="required">
<xref linkend="popt"/>
</para>
<bridgehead renderas="sect4">Recommended</bridgehead>
<para role="recommended">
<xref linkend="fcron"/> (runtime)
</para>
<bridgehead renderas="sect4">Optional</bridgehead>
<para role="optional">
An <xref linkend="server-mail"/> (runtime)
</para>
<para condition="html" role="usernotes">User Notes:
<ulink url="&blfs-wiki;/logrotate"/>
</para>
</sect2>
<sect2 role="installation">
<title>Installation of Logrotate</title>
<para>
Install <application>logrotate</application> by running the following
command:
</para>
<screen><userinput>make</userinput></screen>
<para>
To test the results, issue: <command>make test</command>.
</para>
<para>
Now, as the <systemitem class="username">root</systemitem> user:
</para>
<screen role="root"><userinput>make MANDIR=/usr/share/man install</userinput></screen>
</sect2>
<sect2 role="commands">
<title>Command Explanations</title>
<para>
<envar>MANDIR=/usr/share/man</envar>: Ensure the man pages are installed in
the correct location.
</para>
</sect2>
<sect2 role="configuration">
<title>Configuring Logrotate</title>
<para><application>Logrotate</application> needs a configuration file,
which must be passed as an argument to the command when executed. Create
the file as the <systemitem class="username">root</systemitem> user:</para>
<screen role="root"><userinput>cat &gt; /etc/logrotate.conf &lt;&lt; EOF
# Begin of /etc/logrotate.conf
# Rotate log files weekly
weekly
# Don't send mail to anybody
nomail
# If the log file is empty, it will not be rotated
notifempty
# Number of backups that will be kept
# This will keep the 2 newest backups only
rotate 2
# Create new empty files after rotating old ones
# This will create empty log files, with owner
# set to root, group set to sys, and permissions 644
create 0664 root sys
# Compress the backups with gzip
compress
# No packages own lastlog or wtmp -- rotate them here
/var/log/wtmp {
monthly
create 0664 root utmp
rotate 1
}
/var/log/lastlog {
monthly
rotate 1
}
# Some packages drop log rotation info in this directory
# so we include any file in it.
include /etc/logrotate.d
# End of /etc/logrotate.conf
EOF</userinput></screen>
<para>Now create the <filename class='directory'>/etc/logrotate.d</filename>
directory as the <systemitem class="username">root</systemitem> user:</para>
<screen role="root"><userinput> mkdir -p /etc/logrotate.d</userinput></screen>
<para>At this point additional log rotation commands can be entered, typically
in the <filename class='directory'>/etc/logrotate.d</filename> directory.
For example:</para>
<screen role="root"><userinput>cat &gt; /etc/logrotate.d/sys.log &lt;&lt; EOF
sys.log {
# If the log file is larger than 100kb, rotate it
size 100k
rotate 5
weekly
postrotate
/bin/killall -HUP syslogd
endscript
}
EOF</userinput></screen>
<para>See the logrotate man page or
<ulink url='http://www.techrepublic.com/article/manage-linux-log-files-with-logrotate/'/>
for more examples.</para>
<para>The command <command>logrotate /etc/logrotate.conf</command> can be
run manually, however, the command should be run daily.
To set up <xref linkend='fcron'/> to run at 3AM daily, root's crontab
should be edited to add:</para>
<screen><literal>0 3 * * * /usr/sbin/logrotate /etc/logrotate.conf</literal></screen>
</sect2>
<sect2 role="content">
<title>Contents</title>
<segmentedlist>
<segtitle>Installed Programs</segtitle>
<segtitle>Installed Library</segtitle>
<segtitle>Installed Directories</segtitle>
<seglistitem>
<seg> logrotate </seg>
<seg> None </seg>
<seg> None </seg>
</seglistitem>
</segmentedlist>
<variablelist>
<bridgehead renderas="sect3">Short Descriptions</bridgehead>
<?dbfo list-presentation="list"?>
<?dbhtml list-presentation="table"?>
<varlistentry id="logrotate-prog">
<term><command>logrotate</command></term>
<listitem>
<para>
performs the log maintenace functions defined in the
configuration files.
</para>
<indexterm zone="logrotate logrotate-prog">
<primary sortas="b-logrotate-prog">logrotate</primary>
</indexterm>
</listitem>
</varlistentry>
</variablelist>
</sect2>
</sect1>