source: general/sysutils/logrotate.xml@ f67554b0

10.0 10.1 11.0 11.1 9.0 9.1 lazarus qt5new trunk upgradedb xry111/intltool xry111/test-20220226
Last change on this file since f67554b0 was f67554b0, checked in by Pierre Labastie <pieere@…>, 3 years ago

Various tweaks for the sake of jhalfs:
dconf, speex, sane: change the second package information to

"Additional Downloads". Include unpack instructions
for the second package in all cases. Also remove
the requirement that the user be in group sane for
building (works without that)

faac, faad2: add remap="test" to tests
rox-filer, logrotate: make some configuration instruction nodump
gnome-menus: make the (almost deprecated) gsettings instruction nodump
ncftp: make second method nodump

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@22010 af4574ff-66df-0310-9fd7-8a98e5e911e0

  • Property mode set to 100644
File size: 9.0 KB
Line 
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 "https://github.com/logrotate/logrotate/releases/download/&logrotate-version;/logrotate-&logrotate-version;.tar.xz">
8 <!ENTITY logrotate-download-ftp " ">
9 <!ENTITY logrotate-md5sum "320046f0b9fc38337e8827d4c5a866a0">
10 <!ENTITY logrotate-size "156 KB">
11 <!ENTITY logrotate-buildsize "4.9 MB">
12 <!ENTITY logrotate-time "0.1 SBU (with tests)">
13]>
14
15<sect1 id="logrotate" xreflabel="logrotate-&logrotate-version;">
16 <?dbhtml filename="logrotate.html"?>
17
18 <sect1info>
19 <othername>$LastChangedBy$</othername>
20 <date>$Date$</date>
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 &lfs84_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" revision="sysv">Recommended</bridgehead>
81 <para role="recommended" revision="sysv">
82 <xref role="runtime" linkend="fcron"/> (runtime)
83 </para>
84
85 <bridgehead renderas="sect4">Optional</bridgehead>
86 <para role="optional">
87 An <xref role="runtime" 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>./configure --prefix=/usr &amp;&amp;
104make</userinput></screen>
105
106 <para>
107 To test the results, issue: <command>make test</command>. One test
108 fails because the very old <command>compress</command> is not
109 present and two tests fail if an MTA is not installed.
110 </para>
111
112 <para>
113 Now, as the <systemitem class="username">root</systemitem> user:
114 </para>
115
116<screen role="root"><userinput>make install</userinput></screen>
117
118 </sect2>
119
120 <sect2 role="configuration">
121 <title>Configuring Logrotate</title>
122
123 <para><application>Logrotate</application> needs a configuration file,
124 which must be passed as an argument to the command when executed. Create
125 the file as the <systemitem class="username">root</systemitem> user:</para>
126
127<screen role="root"><userinput>cat &gt; /etc/logrotate.conf &lt;&lt; EOF
128<literal># Begin of /etc/logrotate.conf
129
130# Rotate log files weekly
131weekly
132
133# Don't mail logs to anybody
134nomail
135
136# If the log file is empty, it will not be rotated
137notifempty
138
139# Number of backups that will be kept
140# This will keep the 2 newest backups only
141rotate 2
142
143# Create new empty files after rotating old ones
144# This will create empty log files, with owner
145# set to root, group set to sys, and permissions 644
146create 0664 root sys
147
148# Compress the backups with gzip
149compress
150
151# No packages own lastlog or wtmp -- rotate them here
152/var/log/wtmp {
153 monthly
154 create 0664 root utmp
155 rotate 1
156}
157
158/var/log/lastlog {
159 monthly
160 rotate 1
161}
162
163# Some packages drop log rotation info in this directory
164# so we include any file in it.
165include /etc/logrotate.d
166
167# End of /etc/logrotate.conf</literal>
168EOF
169
170chmod -v 0644 /etc/logrotate.conf</userinput></screen>
171
172 <para>Now create the <filename class='directory'>/etc/logrotate.d</filename>
173 directory as the <systemitem class="username">root</systemitem> user:</para>
174
175<screen role="root"><userinput> mkdir -p /etc/logrotate.d</userinput></screen>
176
177 <para>At this point additional log rotation commands can be entered, typically
178 in the <filename class='directory'>/etc/logrotate.d</filename> directory.
179 For example:</para>
180
181<screen role="root"><userinput>cat &gt; /etc/logrotate.d/sys.log &lt;&lt; EOF
182<literal>/var/log/sys.log {
183 # If the log file is larger than 100kb, rotate it
184 size 100k
185 rotate 5
186 weekly
187 postrotate
188 /bin/killall -HUP syslogd
189 endscript
190}</literal>
191EOF
192
193chmod -v 0644 /etc/logrotate.d/sys.log</userinput></screen>
194
195 <para>You can designate multiple files in one entry:</para>
196
197<screen role="nodump"><userinput>cat &gt; /etc/logrotate.d/example.log &lt;&lt; EOF
198<literal>file1
199file2
200file3 {
201 ...
202 postrotate
203 ...
204 endscript
205}</literal>
206EOF
207
208chmod -v 0644 /etc/logrotate.d/example.log</userinput></screen>
209
210 <para>You can use in the same line the list of files: file1 file2 file3.
211 See the logrotate man page or
212 <ulink url='http://www.techrepublic.com/article/manage-linux-log-files-with-logrotate/'/>
213 for more examples.</para>
214
215 <para>The command <command>logrotate /etc/logrotate.conf</command> can be
216 run manually, however, the command should be run daily.
217 Other useful commands are <command>logrotate -d /etc/logrotate.conf</command>
218 for debugging purposes and <command>logrotate -f /etc/logrotate.conf</command>
219 forcing the logrotate commands to be run immediately. Combining the previous
220 options <option>-df</option>, you can debug the effect of the force command.
221 When debugging, the command is only simulated, not really run, thus, eventual
222 non-existing errors appear, when some intermediate files are expected,
223 because they are not actually created.</para>
224
225 <para>
226 To run the <command>logrotate</command> daily,
227 <phrase revision="sysv">if you've installed
228 <xref linkend="fcron"/> and completed the section on periodic jobs,
229 execute</phrase><phrase revision="systemd">execute</phrase> the following
230 commands, as the <systemitem class="username">root</systemitem> user,
231 to create a <phrase revision="sysv">daily cron job:</phrase>
232 <phrase revision="systemd">systemd timer to run daily at 3:00 A.M.
233 (local time):</phrase>
234 </para>
235
236<screen role="root" revision="sysv"><userinput>install -vdm 754 /etc/cron.daily &amp;&amp;
237cat &gt; /etc/cron.daily/logrotate.sh &lt;&lt; "EOF" &amp;&amp;
238<literal>#!/bin/bash
239/usr/sbin/logrotate /etc/logrotate.conf</literal>
240EOF
241chmod 754 /etc/cron.daily/logrotate.sh</userinput></screen>
242
243<screen role="root" revision="systemd"><userinput>cat &gt; /lib/systemd/system/logrotate.service &lt;&lt; "EOF" &amp;&amp;
244<literal>[Unit]
245Description=Runs the logrotate command
246Documentation=logrotate(8)
247DefaultDependencies=no
248After=local-fs.target
249Before=shutdown.target
250
251[Service]
252Type=oneshot
253RemainAfterExit=yes
254ExecStart=/usr/sbin/logrotate /etc/logrotate.conf</literal>
255EOF
256cat &gt; /lib/systemd/system/logroate.timer &lt;&lt; "EOF" &amp;&amp;
257<literal>[Unit]
258Description=Runs the logrotate command daily at 3:00 AM
259
260[Timer]
261OnCalendar=*-*-* 3:00:00
262Persistent=true
263
264[Install]
265WantedBy=timers.target</literal>
266EOF
267systemctl enable logrotate.timer</userinput></screen>
268
269 </sect2>
270
271 <sect2 role="content">
272 <title>Contents</title>
273
274 <segmentedlist>
275 <segtitle>Installed Programs</segtitle>
276 <segtitle>Installed Library</segtitle>
277 <segtitle>Installed Directories</segtitle>
278
279 <seglistitem>
280 <seg> logrotate </seg>
281 <seg> None </seg>
282 <seg> None </seg>
283 </seglistitem>
284 </segmentedlist>
285
286 <variablelist>
287 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
288 <?dbfo list-presentation="list"?>
289 <?dbhtml list-presentation="table"?>
290
291 <varlistentry id="logrotate-prog">
292 <term><command>logrotate</command></term>
293 <listitem>
294 <para>
295 performs the log maintenance functions defined in the
296 configuration files.
297 </para>
298 <indexterm zone="logrotate logrotate-prog">
299 <primary sortas="b-logrotate-prog">logrotate</primary>
300 </indexterm>
301 </listitem>
302 </varlistentry>
303
304 </variablelist>
305
306 </sect2>
307
308</sect1>
Note: See TracBrowser for help on using the repository browser.