[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 |
|
---|
[1fd59b5] | 7 | <!ENTITY logrotate-download-http "https://github.com/logrotate/logrotate/releases/download/&logrotate-version;/logrotate-&logrotate-version;.tar.xz">
|
---|
[92c4b7a] | 8 | <!ENTITY logrotate-download-ftp " ">
|
---|
[1fd59b5] | 9 | <!ENTITY logrotate-md5sum "3a9280e4caeb837427a2d54518fbcdac">
|
---|
| 10 | <!ENTITY logrotate-size "132 KB">
|
---|
| 11 | <!ENTITY logrotate-buildsize "1.7 MB">
|
---|
| 12 | <!ENTITY logrotate-time "0.1 SBU">
|
---|
[92c4b7a] | 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>
|
---|
[f3429309] | 33 | The <application>logrotate</application> package allows automatic rotation,
|
---|
| 34 | compression, removal, and mailing of log files.
|
---|
[92c4b7a] | 35 | </para>
|
---|
| 36 |
|
---|
[b62a2a68] | 37 | &lfs82_checked;
|
---|
[92c4b7a] | 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">
|
---|
[572553b] | 82 | <xref role="runtime" linkend="fcron"/> (runtime)
|
---|
[92c4b7a] | 83 | </para>
|
---|
| 84 |
|
---|
| 85 | <bridgehead renderas="sect4">Optional</bridgehead>
|
---|
| 86 | <para role="optional">
|
---|
[572553b] | 87 | An <xref role="runtime" linkend="server-mail"/> (runtime)
|
---|
[92c4b7a] | 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 |
|
---|
[1fd59b5] | 103 | <screen><userinput>sed -i '/exit 5/s/^/echo uncompress failed -- skipping #/' test/test &&
|
---|
| 104 |
|
---|
| 105 | ./configure --prefix=/usr &&
|
---|
[e909f17] | 106 | make</userinput></screen>
|
---|
[92c4b7a] | 107 |
|
---|
| 108 | <para>
|
---|
[f3429309] | 109 | To test the results, issue: <command>make test</command>.
|
---|
[92c4b7a] | 110 | </para>
|
---|
| 111 |
|
---|
| 112 | <para>
|
---|
| 113 | Now, as the <systemitem class="username">root</systemitem> user:
|
---|
| 114 | </para>
|
---|
| 115 |
|
---|
[e909f17] | 116 | <screen role="root"><userinput>make install</userinput></screen>
|
---|
[92c4b7a] | 117 |
|
---|
| 118 | </sect2>
|
---|
[1dd7b0ae] | 119 |
|
---|
[92c4b7a] | 120 | <sect2 role="commands">
|
---|
| 121 | <title>Command Explanations</title>
|
---|
| 122 |
|
---|
| 123 | <para>
|
---|
[1fd59b5] | 124 | <command>sed ... test/test</command>: Prevents the tests from
|
---|
| 125 | failing due to a problem in the test script.
|
---|
[92c4b7a] | 126 | </para>
|
---|
| 127 |
|
---|
[1dd7b0ae] | 128 | </sect2>
|
---|
[92c4b7a] | 129 |
|
---|
| 130 | <sect2 role="configuration">
|
---|
| 131 | <title>Configuring Logrotate</title>
|
---|
| 132 |
|
---|
[f3429309] | 133 | <para><application>Logrotate</application> needs a configuration file,
|
---|
| 134 | which must be passed as an argument to the command when executed. Create
|
---|
[92c4b7a] | 135 | the file as the <systemitem class="username">root</systemitem> user:</para>
|
---|
| 136 |
|
---|
| 137 | <screen role="root"><userinput>cat > /etc/logrotate.conf << EOF
|
---|
| 138 | # Begin of /etc/logrotate.conf
|
---|
| 139 |
|
---|
| 140 | # Rotate log files weekly
|
---|
| 141 | weekly
|
---|
| 142 |
|
---|
[3656def] | 143 | # Don't mail logs to anybody
|
---|
[92c4b7a] | 144 | nomail
|
---|
| 145 |
|
---|
| 146 | # If the log file is empty, it will not be rotated
|
---|
| 147 | notifempty
|
---|
| 148 |
|
---|
| 149 | # Number of backups that will be kept
|
---|
| 150 | # This will keep the 2 newest backups only
|
---|
| 151 | rotate 2
|
---|
| 152 |
|
---|
| 153 | # Create new empty files after rotating old ones
|
---|
| 154 | # This will create empty log files, with owner
|
---|
| 155 | # set to root, group set to sys, and permissions 644
|
---|
| 156 | create 0664 root sys
|
---|
| 157 |
|
---|
| 158 | # Compress the backups with gzip
|
---|
| 159 | compress
|
---|
| 160 |
|
---|
| 161 | # No packages own lastlog or wtmp -- rotate them here
|
---|
| 162 | /var/log/wtmp {
|
---|
| 163 | monthly
|
---|
| 164 | create 0664 root utmp
|
---|
| 165 | rotate 1
|
---|
| 166 | }
|
---|
| 167 |
|
---|
| 168 | /var/log/lastlog {
|
---|
| 169 | monthly
|
---|
| 170 | rotate 1
|
---|
| 171 | }
|
---|
| 172 |
|
---|
| 173 | # Some packages drop log rotation info in this directory
|
---|
| 174 | # so we include any file in it.
|
---|
| 175 | include /etc/logrotate.d
|
---|
| 176 |
|
---|
| 177 | # End of /etc/logrotate.conf
|
---|
[58720a7b] | 178 | EOF
|
---|
| 179 |
|
---|
| 180 | chmod -v 0644 /etc/logrotate.conf</userinput></screen>
|
---|
[92c4b7a] | 181 |
|
---|
| 182 | <para>Now create the <filename class='directory'>/etc/logrotate.d</filename>
|
---|
| 183 | directory as the <systemitem class="username">root</systemitem> user:</para>
|
---|
| 184 |
|
---|
| 185 | <screen role="root"><userinput> mkdir -p /etc/logrotate.d</userinput></screen>
|
---|
| 186 |
|
---|
[f3429309] | 187 | <para>At this point additional log rotation commands can be entered, typically
|
---|
[92c4b7a] | 188 | in the <filename class='directory'>/etc/logrotate.d</filename> directory.
|
---|
| 189 | For example:</para>
|
---|
| 190 |
|
---|
| 191 | <screen role="root"><userinput>cat > /etc/logrotate.d/sys.log << EOF
|
---|
[58720a7b] | 192 | /var/log/sys.log {
|
---|
[92c4b7a] | 193 | # If the log file is larger than 100kb, rotate it
|
---|
| 194 | size 100k
|
---|
| 195 | rotate 5
|
---|
| 196 | weekly
|
---|
| 197 | postrotate
|
---|
| 198 | /bin/killall -HUP syslogd
|
---|
| 199 | endscript
|
---|
| 200 | }
|
---|
[58720a7b] | 201 | EOF
|
---|
| 202 |
|
---|
| 203 | chmod -v 0644 /etc/logrotate.d/sys.log</userinput></screen>
|
---|
| 204 |
|
---|
| 205 | <para>You can designate multiple files in one entry:</para>
|
---|
| 206 |
|
---|
| 207 | <screen role="root"><userinput>cat > /etc/logrotate.d/example.log << EOF
|
---|
| 208 | file1
|
---|
| 209 | file2
|
---|
| 210 | file3 {
|
---|
| 211 | ...
|
---|
| 212 | postrotate
|
---|
| 213 | ...
|
---|
| 214 | endscript
|
---|
| 215 | }
|
---|
| 216 | EOF
|
---|
| 217 |
|
---|
| 218 | chmod -v 0644 /etc/logrotate.d/example.log</userinput></screen>
|
---|
[92c4b7a] | 219 |
|
---|
[58720a7b] | 220 | <para>You can use in the same line the list of files: file1 file2 file3.
|
---|
[f3429309] | 221 | See the logrotate man page or
|
---|
[92c4b7a] | 222 | <ulink url='http://www.techrepublic.com/article/manage-linux-log-files-with-logrotate/'/>
|
---|
| 223 | for more examples.</para>
|
---|
| 224 |
|
---|
| 225 | <para>The command <command>logrotate /etc/logrotate.conf</command> can be
|
---|
[58720a7b] | 226 | run manually, however, the command should be run daily.
|
---|
| 227 | Other useful commands are <command>logrotate -d /etc/logrotate.conf</command>
|
---|
| 228 | for debugging purposes and <command>logrotate -f /etc/logrotate.conf</command>
|
---|
| 229 | forcing the logrotate commands to be run immediately. Combining the previous
|
---|
| 230 | options <option>-df</option>, you can debug the effect of the force command.
|
---|
| 231 | When debugging, the command is only simulated, not really run, thus, eventual
|
---|
| 232 | non-existing errors appear, when some intermediate files are expected,
|
---|
| 233 | because they are not actually created.</para>
|
---|
| 234 |
|
---|
| 235 | <para>To set up <xref linkend='fcron'/> to run
|
---|
| 236 | <command>logrotate ...</command> at 3AM daily, root's crontab should be
|
---|
| 237 | edited to add:</para>
|
---|
[92c4b7a] | 238 |
|
---|
| 239 | <screen><literal>0 3 * * * /usr/sbin/logrotate /etc/logrotate.conf</literal></screen>
|
---|
| 240 |
|
---|
| 241 |
|
---|
| 242 | </sect2>
|
---|
| 243 |
|
---|
| 244 | <sect2 role="content">
|
---|
| 245 | <title>Contents</title>
|
---|
| 246 |
|
---|
| 247 | <segmentedlist>
|
---|
| 248 | <segtitle>Installed Programs</segtitle>
|
---|
| 249 | <segtitle>Installed Library</segtitle>
|
---|
| 250 | <segtitle>Installed Directories</segtitle>
|
---|
| 251 |
|
---|
| 252 | <seglistitem>
|
---|
| 253 | <seg> logrotate </seg>
|
---|
| 254 | <seg> None </seg>
|
---|
| 255 | <seg> None </seg>
|
---|
| 256 | </seglistitem>
|
---|
| 257 | </segmentedlist>
|
---|
| 258 |
|
---|
| 259 | <variablelist>
|
---|
| 260 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
| 261 | <?dbfo list-presentation="list"?>
|
---|
| 262 | <?dbhtml list-presentation="table"?>
|
---|
| 263 |
|
---|
| 264 | <varlistentry id="logrotate-prog">
|
---|
| 265 | <term><command>logrotate</command></term>
|
---|
| 266 | <listitem>
|
---|
| 267 | <para>
|
---|
[f3429309] | 268 | performs the log maintenance functions defined in the
|
---|
[92c4b7a] | 269 | configuration files.
|
---|
| 270 | </para>
|
---|
| 271 | <indexterm zone="logrotate logrotate-prog">
|
---|
| 272 | <primary sortas="b-logrotate-prog">logrotate</primary>
|
---|
| 273 | </indexterm>
|
---|
| 274 | </listitem>
|
---|
| 275 | </varlistentry>
|
---|
| 276 |
|
---|
| 277 | </variablelist>
|
---|
| 278 |
|
---|
| 279 | </sect2>
|
---|
| 280 |
|
---|
| 281 | </sect1>
|
---|