source: general/sysutils/logrotate.xml@ a1f2d184

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 7.10 7.6 7.7 7.8 7.9 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 krejzi/svn lazarus lxqt nosym 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 a1f2d184 was 3656def, checked in by Ken Moffat <ken@…>, 10 years ago

Clarify comment in logrotate.conf

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

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