glfs/general/sysutils/logrotate.xml
Bruce Dubbs db6385bffd Update to cups-filters-1.21.5.
Update to poppler-0.72.0. 
Update to btrfs-progs-v4.19.1. 
Update to logrotate-3.15.0. 
Update to nettle-3.4.1. 
Update to git-2.19.2. 



git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@20787 af4574ff-66df-0310-9fd7-8a98e5e911e0
2018-12-09 19:33:47 +00:00

272 lines
7.6 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 "https://github.com/logrotate/logrotate/releases/download/&logrotate-version;/logrotate-&logrotate-version;.tar.xz">
<!ENTITY logrotate-download-ftp " ">
<!ENTITY logrotate-md5sum "320046f0b9fc38337e8827d4c5a866a0">
<!ENTITY logrotate-size "156 KB">
<!ENTITY logrotate-buildsize "4.9 MB">
<!ENTITY logrotate-time "0.1 SBU (with tests)">
]>
<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>
&lfs83_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 role="runtime" linkend="fcron"/> (runtime)
</para>
<bridgehead renderas="sect4">Optional</bridgehead>
<para role="optional">
An <xref role="runtime" 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>./configure --prefix=/usr &amp;&amp;
make</userinput></screen>
<para>
To test the results, issue: <command>make test</command>. One test
fails because the very old <command>compress</command> is not
present and two tests fail if an MTA is not installed.
</para>
<para>
Now, as the <systemitem class="username">root</systemitem> user:
</para>
<screen role="root"><userinput>make install</userinput></screen>
</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 mail logs 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
chmod -v 0644 /etc/logrotate.conf</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
/var/log/sys.log {
# If the log file is larger than 100kb, rotate it
size 100k
rotate 5
weekly
postrotate
/bin/killall -HUP syslogd
endscript
}
EOF
chmod -v 0644 /etc/logrotate.d/sys.log</userinput></screen>
<para>You can designate multiple files in one entry:</para>
<screen role="root"><userinput>cat &gt; /etc/logrotate.d/example.log &lt;&lt; EOF
file1
file2
file3 {
...
postrotate
...
endscript
}
EOF
chmod -v 0644 /etc/logrotate.d/example.log</userinput></screen>
<para>You can use in the same line the list of files: file1 file2 file3.
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.
Other useful commands are <command>logrotate -d /etc/logrotate.conf</command>
for debugging purposes and <command>logrotate -f /etc/logrotate.conf</command>
forcing the logrotate commands to be run immediately. Combining the previous
options <option>-df</option>, you can debug the effect of the force command.
When debugging, the command is only simulated, not really run, thus, eventual
non-existing errors appear, when some intermediate files are expected,
because they are not actually created.</para>
<para>To set up <xref linkend='fcron'/> to run
<command>logrotate ...</command> 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 maintenance 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>