source: general/sysutils/logrotate.xml@ e704393

12.2 gimp3 lazarus trunk xry111/for-12.3 xry111/spidermonkey128
Last change on this file since e704393 was dd8803c, checked in by Bruce Dubbs <bdubbs@…>, 3 months ago

Update to logrotate-3.22.0.

  • Property mode set to 100644
File size: 8.8 KB
RevLine 
[ab4fdfc]1<?xml version="1.0" encoding="UTF-8"?>
[92c4b7a]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 " ">
[dd8803c]9 <!ENTITY logrotate-md5sum "2386501a53ff086f44eeada2b27d50b8">
10 <!ENTITY logrotate-size "172 KB">
11 <!ENTITY logrotate-buildsize "2.6 MB (add 38 MB for tests)">
12 <!ENTITY logrotate-time "less than 0.1 SBU (add 0.1 SBU for tests)">
[92c4b7a]13]>
14
15<sect1 id="logrotate" xreflabel="logrotate-&logrotate-version;">
16 <?dbhtml filename="logrotate.html"?>
17
18
19 <title>Logrotate-&logrotate-version;</title>
20
21 <indexterm zone="logrotate">
22 <primary sortas="a-logrotate">logrotate</primary>
23 </indexterm>
24
25 <sect2 role="package">
26 <title>Introduction to Logrotate</title>
27
28 <para>
[b1532549]29 The <application>logrotate</application> package allows automatic
30 rotation, compression, removal, and mailing of log files.
[92c4b7a]31 </para>
32
[868811b]33 &lfs121_checked;
[92c4b7a]34
35 <bridgehead renderas="sect3">Package Information</bridgehead>
36 <itemizedlist spacing="compact">
37 <listitem>
38 <para>
39 Download (HTTP): <ulink url="&logrotate-download-http;"/>
40 </para>
41 </listitem>
42 <listitem>
43 <para>
44 Download (FTP): <ulink url="&logrotate-download-ftp;"/>
45 </para>
46 </listitem>
47 <listitem>
48 <para>
49 Download MD5 sum: &logrotate-md5sum;
50 </para>
51 </listitem>
52 <listitem>
53 <para>
54 Download size: &logrotate-size;
55 </para>
56 </listitem>
57 <listitem>
58 <para>
59 Estimated disk space required: &logrotate-buildsize;
60 </para>
61 </listitem>
62 <listitem>
63 <para>
64 Estimated build time: &logrotate-time;
65 </para>
66 </listitem>
67 </itemizedlist>
68
69 <bridgehead renderas="sect3">Logrotate Dependencies</bridgehead>
70
71 <bridgehead renderas="sect4">Required</bridgehead>
72 <para role="required">
73 <xref linkend="popt"/>
74 </para>
75
[0f7ad57]76 <bridgehead renderas="sect4" revision="sysv">Recommended</bridgehead>
77 <para role="recommended" revision="sysv">
[572553b]78 <xref role="runtime" linkend="fcron"/> (runtime)
[92c4b7a]79 </para>
80
81 <bridgehead renderas="sect4">Optional</bridgehead>
82 <para role="optional">
[572553b]83 An <xref role="runtime" linkend="server-mail"/> (runtime)
[92c4b7a]84 </para>
85
86 </sect2>
87
88 <sect2 role="installation">
89 <title>Installation of Logrotate</title>
90
91 <para>
92 Install <application>logrotate</application> by running the following
93 command:
94 </para>
95
[b4dbcb0]96<screen><userinput>./configure --prefix=/usr &amp;&amp;
[e909f17]97make</userinput></screen>
[92c4b7a]98
99 <para>
[dd8803c]100 To test the results, issue: <command>make test</command>.
101 Two tests fail if an MTA is not installed.
[92c4b7a]102 </para>
103
104 <para>
105 Now, as the <systemitem class="username">root</systemitem> user:
106 </para>
107
[e909f17]108<screen role="root"><userinput>make install</userinput></screen>
[92c4b7a]109
110 </sect2>
[1dd7b0ae]111
[92c4b7a]112 <sect2 role="configuration">
[b1532549]113 <title>Configuring Logrotate</title>
[92c4b7a]114
[b1532549]115 <para>
116 <application>Logrotate</application> needs a configuration file,
117 which must be passed as an argument to the command when executed. Create
118 the file as the <systemitem class="username">root</systemitem> user:
119 </para>
[92c4b7a]120
121<screen role="root"><userinput>cat &gt; /etc/logrotate.conf &lt;&lt; EOF
[b4dbcb0]122<literal># Begin /etc/logrotate.conf
[92c4b7a]123
124# Rotate log files weekly
125weekly
126
[3656def]127# Don't mail logs to anybody
[92c4b7a]128nomail
129
130# If the log file is empty, it will not be rotated
131notifempty
132
133# Number of backups that will be kept
134# This will keep the 2 newest backups only
135rotate 2
136
137# Create new empty files after rotating old ones
138# This will create empty log files, with owner
[b4dbcb0]139# set to root, group set to sys, and permissions 664
[92c4b7a]140create 0664 root sys
141
142# Compress the backups with gzip
143compress
144
145# No packages own lastlog or wtmp -- rotate them here
146/var/log/wtmp {
147 monthly
148 create 0664 root utmp
149 rotate 1
150}
151
152/var/log/lastlog {
153 monthly
154 rotate 1
155}
156
157# Some packages drop log rotation info in this directory
158# so we include any file in it.
159include /etc/logrotate.d
160
[b4dbcb0]161# End /etc/logrotate.conf</literal>
[58720a7b]162EOF
163
164chmod -v 0644 /etc/logrotate.conf</userinput></screen>
[92c4b7a]165
[b1532549]166 <para>
167 Now create the <filename class='directory'>/etc/logrotate.d</filename>
168 directory as the <systemitem class="username">root</systemitem> user:
169 </para>
[92c4b7a]170
[b4dbcb0]171<screen role="root"><userinput>mkdir -p /etc/logrotate.d</userinput></screen>
[92c4b7a]172
[b1532549]173 <para>
174 At this point additional log rotation commands can be entered, typically
175 in the <filename class='directory'>/etc/logrotate.d</filename> directory.
176 For example:
177 </para>
[92c4b7a]178
[a09f080]179<screen role="nodump"><userinput>cat &gt; /etc/logrotate.d/sys.log &lt;&lt; EOF
[51dfb3e]180<literal>/var/log/sys.log {
[92c4b7a]181 # If the log file is larger than 100kb, rotate it
182 size 100k
183 rotate 5
184 weekly
185 postrotate
186 /bin/killall -HUP syslogd
187 endscript
[51dfb3e]188}</literal>
[58720a7b]189EOF
190
191chmod -v 0644 /etc/logrotate.d/sys.log</userinput></screen>
192
[b1532549]193 <para>
194 You can designate multiple files in one entry:
195 </para>
[58720a7b]196
[f67554b0]197<screen role="nodump"><userinput>cat &gt; /etc/logrotate.d/example.log &lt;&lt; EOF
[51dfb3e]198<literal>file1
[58720a7b]199file2
200file3 {
201 ...
202 postrotate
203 ...
204 endscript
[51dfb3e]205}</literal>
[58720a7b]206EOF
207
208chmod -v 0644 /etc/logrotate.d/example.log</userinput></screen>
[92c4b7a]209
[b1532549]210 <para>
211 You can use in the same line the list of files: file1 file2 file3.
212 See the logrotate man page or <ulink
[6e2eb5cf]213 url='https://www.techrepublic.com/article/manage-linux-log-files-with-logrotate/'/>
[b1532549]214 for more examples.
215 </para>
216
217 <para>
218 The command <command>logrotate /etc/logrotate.conf</command> can be
219 run manually, however, the command should be run daily.
220 Other useful commands are <command>logrotate -d
221 /etc/logrotate.conf</command> for debugging purposes and
222 <command>logrotate -f /etc/logrotate.conf</command> forcing the
223 logrotate commands to be run immediately. Combining the previous options
224 <option>-df</option>, you can debug the effect of the force command.
[75cf6e3]225 When debugging, the commands are only simulated and are not actually run.
226 As a result, errors about files not existing will eventually appear because
227 the files are not actually created.
[b1532549]228 </para>
[58720a7b]229
[0f7ad57]230 <para>
[b4dbcb0]231 To run the <command>logrotate</command> command daily,
[0f7ad57]232 <phrase revision="sysv">if you've installed
233 <xref linkend="fcron"/> and completed the section on periodic jobs,
234 execute</phrase><phrase revision="systemd">execute</phrase> the following
235 commands, as the <systemitem class="username">root</systemitem> user,
236 to create a <phrase revision="sysv">daily cron job:</phrase>
237 <phrase revision="systemd">systemd timer to run daily at 3:00 A.M.
238 (local time):</phrase>
239 </para>
240
[914dd13]241<screen role="root" revision="sysv"><userinput>cat &gt; /etc/cron.daily/logrotate.sh &lt;&lt; "EOF" &amp;&amp;
[0f7ad57]242<literal>#!/bin/bash
243/usr/sbin/logrotate /etc/logrotate.conf</literal>
244EOF
245chmod 754 /etc/cron.daily/logrotate.sh</userinput></screen>
246
[d0d2c85a]247<screen role="root" revision="systemd"><userinput>cat &gt; /usr/lib/systemd/system/logrotate.service &lt;&lt; "EOF" &amp;&amp;
[0f7ad57]248<literal>[Unit]
249Description=Runs the logrotate command
[7b75894]250Documentation=man:logrotate(8)
[0f7ad57]251DefaultDependencies=no
252After=local-fs.target
253Before=shutdown.target
254
255[Service]
256Type=oneshot
257RemainAfterExit=yes
258ExecStart=/usr/sbin/logrotate /etc/logrotate.conf</literal>
259EOF
[d0d2c85a]260cat &gt; /usr/lib/systemd/system/logrotate.timer &lt;&lt; "EOF" &amp;&amp;
[0f7ad57]261<literal>[Unit]
262Description=Runs the logrotate command daily at 3:00 AM
[92c4b7a]263
[0f7ad57]264[Timer]
265OnCalendar=*-*-* 3:00:00
266Persistent=true
[92c4b7a]267
[0f7ad57]268[Install]
269WantedBy=timers.target</literal>
270EOF
271systemctl enable logrotate.timer</userinput></screen>
[92c4b7a]272
273 </sect2>
274
275 <sect2 role="content">
276 <title>Contents</title>
277
278 <segmentedlist>
279 <segtitle>Installed Programs</segtitle>
280 <segtitle>Installed Library</segtitle>
281 <segtitle>Installed Directories</segtitle>
282
283 <seglistitem>
284 <seg> logrotate </seg>
285 <seg> None </seg>
286 <seg> None </seg>
287 </seglistitem>
288 </segmentedlist>
289
290 <variablelist>
291 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
292 <?dbfo list-presentation="list"?>
293 <?dbhtml list-presentation="table"?>
294
295 <varlistentry id="logrotate-prog">
296 <term><command>logrotate</command></term>
297 <listitem>
298 <para>
[f3429309]299 performs the log maintenance functions defined in the
[4c24eb0a]300 configuration files
[92c4b7a]301 </para>
302 <indexterm zone="logrotate logrotate-prog">
303 <primary sortas="b-logrotate-prog">logrotate</primary>
304 </indexterm>
305 </listitem>
306 </varlistentry>
307
308 </variablelist>
309
310 </sect2>
311
312</sect1>
Note: See TracBrowser for help on using the repository browser.