source: general/sysutils/logrotate.xml@ 0853fa7

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 8.3 8.4 9.0 9.1 basic bdubbs/svn elogind kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts lazarus lxqt perl-modules plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition trunk upgradedb xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since 0853fa7 was b79cece1, checked in by Thomas Trepl <thomas@…>, 6 years ago

Fix missing -i in sed; fix a typo

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

  • Property mode set to 100644
File size: 8.1 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 "3a9280e4caeb837427a2d54518fbcdac">
10 <!ENTITY logrotate-size "132 KB">
11 <!ENTITY logrotate-buildsize "1.7 MB">
12 <!ENTITY logrotate-time "0.1 SBU">
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 &lfs82_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 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>sed -i '/exit 5/s/^/echo uncompress failed -- skipping #/' test/test &amp;&amp;
104
105sed -i 's/-Werror//' Makefile.am &amp;&amp;
106./autogen.sh &amp;&amp;
107./configure --prefix=/usr &amp;&amp;
108make</userinput></screen>
109
110 <para>
111 To test the results, issue: <command>make test</command>.
112 </para>
113
114 <para>
115 Now, as the <systemitem class="username">root</systemitem> user:
116 </para>
117
118<screen role="root"><userinput>make install</userinput></screen>
119
120 </sect2>
121
122 <sect2 role="commands">
123 <title>Command Explanations</title>
124
125 <para>
126 <command>sed ... test/test</command>: Prevents the tests from
127 failing due to a problem in the test script.
128 </para>
129
130 <para>
131 <command>sed -i '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
136 </sect2>
137
138 <sect2 role="configuration">
139 <title>Configuring Logrotate</title>
140
141 <para><application>Logrotate</application> needs a configuration file,
142 which must be passed as an argument to the command when executed. Create
143 the file as the <systemitem class="username">root</systemitem> user:</para>
144
145<screen role="root"><userinput>cat &gt; /etc/logrotate.conf &lt;&lt; EOF
146# Begin of /etc/logrotate.conf
147
148# Rotate log files weekly
149weekly
150
151# Don't mail logs to anybody
152nomail
153
154# If the log file is empty, it will not be rotated
155notifempty
156
157# Number of backups that will be kept
158# This will keep the 2 newest backups only
159rotate 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
164create 0664 root sys
165
166# Compress the backups with gzip
167compress
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.
183include /etc/logrotate.d
184
185# End of /etc/logrotate.conf
186EOF
187
188chmod -v 0644 /etc/logrotate.conf</userinput></screen>
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
195 <para>At this point additional log rotation commands can be entered, typically
196 in the <filename class='directory'>/etc/logrotate.d</filename> directory.
197 For example:</para>
198
199<screen role="root"><userinput>cat &gt; /etc/logrotate.d/sys.log &lt;&lt; EOF
200/var/log/sys.log {
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}
209EOF
210
211chmod -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 &gt; /etc/logrotate.d/example.log &lt;&lt; EOF
216file1
217file2
218file3 {
219 ...
220 postrotate
221 ...
222 endscript
223}
224EOF
225
226chmod -v 0644 /etc/logrotate.d/example.log</userinput></screen>
227
228 <para>You can use in the same line the list of files: file1 file2 file3.
229 See the logrotate man page or
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
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>
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>
276 performs the log maintenance functions defined in the
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>
Note: See TracBrowser for help on using the repository browser.