[92c4b7a] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
| 4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 |
|
---|
| 7 | <!ENTITY logrotate-download-http "http://fedorahosted.org/releases/l/o/logrotate/logrotate-&logrotate-version;.tar.gz">
|
---|
| 8 | <!ENTITY logrotate-download-ftp " ">
|
---|
| 9 | <!ENTITY logrotate-md5sum "99e08503ef24c3e2e3ff74cc5f3be213">
|
---|
| 10 | <!ENTITY logrotate-size "64 KB">
|
---|
| 11 | <!ENTITY logrotate-buildsize "1.3 MB">
|
---|
| 12 | <!ENTITY logrotate-time "less than 0.1 SBU">
|
---|
| 13 | ]>
|
---|
| 14 |
|
---|
| 15 | <sect1 id="logrotate" xreflabel="logrotate-&logrotate-version;">
|
---|
| 16 | <?dbhtml filename="logrotate.html"?>
|
---|
| 17 |
|
---|
| 18 | <sect1info>
|
---|
[bc5778f] | 19 | <othername>$LastChangedBy$</othername>
|
---|
| 20 | <date>$Date$</date>
|
---|
[92c4b7a] | 21 | </sect1info>
|
---|
| 22 |
|
---|
| 23 | <title>Logrotate-&logrotate-version;</title>
|
---|
| 24 |
|
---|
| 25 | <indexterm zone="logrotate">
|
---|
| 26 | <primary sortas="a-logrotate">logrotate</primary>
|
---|
| 27 | </indexterm>
|
---|
| 28 |
|
---|
| 29 | <sect2 role="package">
|
---|
| 30 | <title>Introduction to Logrotate</title>
|
---|
| 31 |
|
---|
| 32 | <para>
|
---|
| 33 | The <application>logrotate</application> package allows automatic rotation,
|
---|
| 34 | compression, removal, and mailing of log files.
|
---|
| 35 | </para>
|
---|
| 36 |
|
---|
| 37 | &lfs75_checked;
|
---|
| 38 |
|
---|
| 39 | <bridgehead renderas="sect3">Package Information</bridgehead>
|
---|
| 40 | <itemizedlist spacing="compact">
|
---|
| 41 | <listitem>
|
---|
| 42 | <para>
|
---|
| 43 | Download (HTTP): <ulink url="&logrotate-download-http;"/>
|
---|
| 44 | </para>
|
---|
| 45 | </listitem>
|
---|
| 46 | <listitem>
|
---|
| 47 | <para>
|
---|
| 48 | Download (FTP): <ulink url="&logrotate-download-ftp;"/>
|
---|
| 49 | </para>
|
---|
| 50 | </listitem>
|
---|
| 51 | <listitem>
|
---|
| 52 | <para>
|
---|
| 53 | Download MD5 sum: &logrotate-md5sum;
|
---|
| 54 | </para>
|
---|
| 55 | </listitem>
|
---|
| 56 | <listitem>
|
---|
| 57 | <para>
|
---|
| 58 | Download size: &logrotate-size;
|
---|
| 59 | </para>
|
---|
| 60 | </listitem>
|
---|
| 61 | <listitem>
|
---|
| 62 | <para>
|
---|
| 63 | Estimated disk space required: &logrotate-buildsize;
|
---|
| 64 | </para>
|
---|
| 65 | </listitem>
|
---|
| 66 | <listitem>
|
---|
| 67 | <para>
|
---|
| 68 | Estimated build time: &logrotate-time;
|
---|
| 69 | </para>
|
---|
| 70 | </listitem>
|
---|
| 71 | </itemizedlist>
|
---|
| 72 |
|
---|
| 73 | <bridgehead renderas="sect3">Logrotate Dependencies</bridgehead>
|
---|
| 74 |
|
---|
| 75 | <bridgehead renderas="sect4">Required</bridgehead>
|
---|
| 76 | <para role="required">
|
---|
| 77 | <xref linkend="popt"/>
|
---|
| 78 | </para>
|
---|
| 79 |
|
---|
| 80 | <bridgehead renderas="sect4">Recommended</bridgehead>
|
---|
| 81 | <para role="recommended">
|
---|
| 82 | <xref linkend="fcron"/> (runtime)
|
---|
| 83 | </para>
|
---|
| 84 |
|
---|
| 85 | <bridgehead renderas="sect4">Optional</bridgehead>
|
---|
| 86 | <para role="optional">
|
---|
| 87 | An <xref linkend="server-mail"/> (runtime)
|
---|
| 88 | </para>
|
---|
| 89 |
|
---|
| 90 | <para condition="html" role="usernotes">User Notes:
|
---|
| 91 | <ulink url="&blfs-wiki;/logrotate"/>
|
---|
| 92 | </para>
|
---|
| 93 | </sect2>
|
---|
| 94 |
|
---|
| 95 | <sect2 role="installation">
|
---|
| 96 | <title>Installation of Logrotate</title>
|
---|
| 97 |
|
---|
| 98 | <para>
|
---|
| 99 | Install <application>logrotate</application> by running the following
|
---|
| 100 | command:
|
---|
| 101 | </para>
|
---|
| 102 |
|
---|
| 103 | <screen><userinput>make</userinput></screen>
|
---|
| 104 |
|
---|
| 105 | <para>
|
---|
| 106 | To test the results, issue: <command>make test</command>.
|
---|
| 107 | </para>
|
---|
| 108 |
|
---|
| 109 | <para>
|
---|
| 110 | Now, as the <systemitem class="username">root</systemitem> user:
|
---|
| 111 | </para>
|
---|
| 112 |
|
---|
| 113 | <screen role="root"><userinput>make MANDIR=/usr/share/man install</userinput></screen>
|
---|
| 114 |
|
---|
| 115 | </sect2>
|
---|
| 116 |
|
---|
| 117 | <sect2 role="commands">
|
---|
| 118 | <title>Command Explanations</title>
|
---|
| 119 |
|
---|
| 120 | <para>
|
---|
| 121 | <envar>MANDIR=/usr/share/man</envar>: Ensure the man pages are installed in
|
---|
| 122 | the correct location.
|
---|
| 123 | </para>
|
---|
| 124 |
|
---|
| 125 | </sect2>
|
---|
| 126 |
|
---|
| 127 | <sect2 role="configuration">
|
---|
| 128 | <title>Configuring Logrotate</title>
|
---|
| 129 |
|
---|
| 130 | <para><application>Logrotate</application> needs a configuration file,
|
---|
| 131 | which must be passed as an argument to the command when executed. Create
|
---|
| 132 | the file as the <systemitem class="username">root</systemitem> user:</para>
|
---|
| 133 |
|
---|
| 134 | <screen role="root"><userinput>cat > /etc/logrotate.conf << EOF
|
---|
| 135 | # Begin of /etc/logrotate.conf
|
---|
| 136 |
|
---|
| 137 | # Rotate log files weekly
|
---|
| 138 | weekly
|
---|
| 139 |
|
---|
| 140 | # Don't send mail to anybody
|
---|
| 141 | nomail
|
---|
| 142 |
|
---|
| 143 | # If the log file is empty, it will not be rotated
|
---|
| 144 | notifempty
|
---|
| 145 |
|
---|
| 146 | # Number of backups that will be kept
|
---|
| 147 | # This will keep the 2 newest backups only
|
---|
| 148 | rotate 2
|
---|
| 149 |
|
---|
| 150 | # Create new empty files after rotating old ones
|
---|
| 151 | # This will create empty log files, with owner
|
---|
| 152 | # set to root, group set to sys, and permissions 644
|
---|
| 153 | create 0664 root sys
|
---|
| 154 |
|
---|
| 155 | # Compress the backups with gzip
|
---|
| 156 | compress
|
---|
| 157 |
|
---|
| 158 | # No packages own lastlog or wtmp -- rotate them here
|
---|
| 159 | /var/log/wtmp {
|
---|
| 160 | monthly
|
---|
| 161 | create 0664 root utmp
|
---|
| 162 | rotate 1
|
---|
| 163 | }
|
---|
| 164 |
|
---|
| 165 | /var/log/lastlog {
|
---|
| 166 | monthly
|
---|
| 167 | rotate 1
|
---|
| 168 | }
|
---|
| 169 |
|
---|
| 170 | # Some packages drop log rotation info in this directory
|
---|
| 171 | # so we include any file in it.
|
---|
| 172 | include /etc/logrotate.d
|
---|
| 173 |
|
---|
| 174 | # End of /etc/logrotate.conf
|
---|
| 175 | EOF</userinput></screen>
|
---|
| 176 |
|
---|
| 177 | <para>Now create the <filename class='directory'>/etc/logrotate.d</filename>
|
---|
| 178 | directory as the <systemitem class="username">root</systemitem> user:</para>
|
---|
| 179 |
|
---|
| 180 | <screen role="root"><userinput> mkdir -p /etc/logrotate.d</userinput></screen>
|
---|
| 181 |
|
---|
| 182 | <para>At this point additional log rotation commands can be entered, typically
|
---|
| 183 | in the <filename class='directory'>/etc/logrotate.d</filename> directory.
|
---|
| 184 | For example:</para>
|
---|
| 185 |
|
---|
| 186 | <screen role="root"><userinput>cat > /etc/logrotate.d/sys.log << EOF
|
---|
| 187 | sys.log {
|
---|
| 188 | # If the log file is larger than 100kb, rotate it
|
---|
| 189 | size 100k
|
---|
| 190 | rotate 5
|
---|
| 191 | weekly
|
---|
| 192 | postrotate
|
---|
| 193 | /bin/killall -HUP syslogd
|
---|
| 194 | endscript
|
---|
| 195 | }
|
---|
| 196 | EOF</userinput></screen>
|
---|
| 197 |
|
---|
| 198 | <para>See the logrotate man page or
|
---|
| 199 | <ulink url='http://www.techrepublic.com/article/manage-linux-log-files-with-logrotate/'/>
|
---|
| 200 | for more examples.</para>
|
---|
| 201 |
|
---|
| 202 | <para>The command <command>logrotate /etc/logrotate.conf</command> can be
|
---|
| 203 | run manually, however, the command should be run daily.
|
---|
| 204 | To set up <xref linkend='fcron'/> to run at 3AM daily, root's crontab
|
---|
| 205 | should be edited to add:</para>
|
---|
| 206 |
|
---|
| 207 | <screen><literal>0 3 * * * /usr/sbin/logrotate /etc/logrotate.conf</literal></screen>
|
---|
| 208 |
|
---|
| 209 |
|
---|
| 210 | </sect2>
|
---|
| 211 |
|
---|
| 212 | <sect2 role="content">
|
---|
| 213 | <title>Contents</title>
|
---|
| 214 |
|
---|
| 215 | <segmentedlist>
|
---|
| 216 | <segtitle>Installed Programs</segtitle>
|
---|
| 217 | <segtitle>Installed Library</segtitle>
|
---|
| 218 | <segtitle>Installed Directories</segtitle>
|
---|
| 219 |
|
---|
| 220 | <seglistitem>
|
---|
| 221 | <seg> logrotate </seg>
|
---|
| 222 | <seg> None </seg>
|
---|
| 223 | <seg> None </seg>
|
---|
| 224 | </seglistitem>
|
---|
| 225 | </segmentedlist>
|
---|
| 226 |
|
---|
| 227 | <variablelist>
|
---|
| 228 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
| 229 | <?dbfo list-presentation="list"?>
|
---|
| 230 | <?dbhtml list-presentation="table"?>
|
---|
| 231 |
|
---|
| 232 | <varlistentry id="logrotate-prog">
|
---|
| 233 | <term><command>logrotate</command></term>
|
---|
| 234 | <listitem>
|
---|
| 235 | <para>
|
---|
| 236 | performs the log maintenace functions defined in the
|
---|
| 237 | configuration files.
|
---|
| 238 | </para>
|
---|
| 239 | <indexterm zone="logrotate logrotate-prog">
|
---|
| 240 | <primary sortas="b-logrotate-prog">logrotate</primary>
|
---|
| 241 | </indexterm>
|
---|
| 242 | </listitem>
|
---|
| 243 | </varlistentry>
|
---|
| 244 |
|
---|
| 245 | </variablelist>
|
---|
| 246 |
|
---|
| 247 | </sect2>
|
---|
| 248 |
|
---|
| 249 | </sect1>
|
---|