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