source: general/sysutils/logrotate.xml@ f8a84b4

10.0 10.1 11.0 7.10 8.0 8.1 8.2 8.3 8.4 9.0 9.1 basic bdubbs/svn elogind ken/refactor-virt lazarus nosym perl-modules qt5new trunk upgradedb xry111/git-date xry111/git-date-for-trunk xry111/git-date-test
Last change on this file since f8a84b4 was f8a84b4, checked in by Ken Moffat <ken@…>, 5 years ago

tags

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

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