source: general/sysutils/logrotate.xml@ a8bf5520

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 8.0 8.1 8.2 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 a8bf5520 was a8bf5520, checked in by Bruce Dubbs <bdubbs@…>, 7 years ago

Tags. Finish general section.

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

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