source: general/sysutils/logrotate.xml@ 6ca1d4e6

trunk
Last change on this file since 6ca1d4e6 was 6ca1d4e6, checked in by Bruce Dubbs <bdubbs@…>, 2 months ago

Package updates
Update to atkmm-2.28.2
Update to pangomm-2.46.1
Update to libepoxy-1.5.8
Update to gtkmm3-3.24.5
Update to logrotate-3.18.1

  • 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 "07d5aba26c350f9ab5730c25a7277751">
10 <!ENTITY logrotate-size "160 KB">
11 <!ENTITY logrotate-buildsize "39 MB (with tests)">
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 <date>$Date$</date>
20 </sect1info>
21
22 <title>Logrotate-&logrotate-version;</title>
23
24 <indexterm zone="logrotate">
25 <primary sortas="a-logrotate">logrotate</primary>
26 </indexterm>
27
28 <sect2 role="package">
29 <title>Introduction to Logrotate</title>
30
31 <para>
32 The <application>logrotate</application> package allows automatic
33 rotation, compression, removal, and mailing of log files.
34 </para>
35
36 &lfs101_checked;
37
38 <bridgehead renderas="sect3">Package Information</bridgehead>
39 <itemizedlist spacing="compact">
40 <listitem>
41 <para>
42 Download (HTTP): <ulink url="&logrotate-download-http;"/>
43 </para>
44 </listitem>
45 <listitem>
46 <para>
47 Download (FTP): <ulink url="&logrotate-download-ftp;"/>
48 </para>
49 </listitem>
50 <listitem>
51 <para>
52 Download MD5 sum: &logrotate-md5sum;
53 </para>
54 </listitem>
55 <listitem>
56 <para>
57 Download size: &logrotate-size;
58 </para>
59 </listitem>
60 <listitem>
61 <para>
62 Estimated disk space required: &logrotate-buildsize;
63 </para>
64 </listitem>
65 <listitem>
66 <para>
67 Estimated build time: &logrotate-time;
68 </para>
69 </listitem>
70 </itemizedlist>
71
72 <bridgehead renderas="sect3">Logrotate Dependencies</bridgehead>
73
74 <bridgehead renderas="sect4">Required</bridgehead>
75 <para role="required">
76 <xref linkend="popt"/>
77 </para>
78
79 <bridgehead renderas="sect4" revision="sysv">Recommended</bridgehead>
80 <para role="recommended" revision="sysv">
81 <xref role="runtime" linkend="fcron"/> (runtime)
82 </para>
83
84 <bridgehead renderas="sect4">Optional</bridgehead>
85 <para role="optional">
86 An <xref role="runtime" linkend="server-mail"/> (runtime)
87 </para>
88
89 <para condition="html" role="usernotes">User Notes:
90 <ulink url="&blfs-wiki;/logrotate"/>
91 </para>
92 </sect2>
93
94 <sect2 role="installation">
95 <title>Installation of Logrotate</title>
96
97 <para>
98 Install <application>logrotate</application> by running the following
99 command:
100 </para>
101
102<screen><userinput>./configure --prefix=/usr &amp;&amp;
103make</userinput></screen>
104
105 <para>
106 To test the results, issue: <command>make test</command>. One test
107 fails because the very old <command>compress</command> is not
108 present and two tests fail if an MTA is not installed.
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="configuration">
120 <title>Configuring Logrotate</title>
121
122 <para>
123 <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:
126 </para>
127
128<screen role="root"><userinput>cat &gt; /etc/logrotate.conf &lt;&lt; EOF
129<literal># Begin /etc/logrotate.conf
130
131# Rotate log files weekly
132weekly
133
134# Don't mail logs to anybody
135nomail
136
137# If the log file is empty, it will not be rotated
138notifempty
139
140# Number of backups that will be kept
141# This will keep the 2 newest backups only
142rotate 2
143
144# Create new empty files after rotating old ones
145# This will create empty log files, with owner
146# set to root, group set to sys, and permissions 664
147create 0664 root sys
148
149# Compress the backups with gzip
150compress
151
152# No packages own lastlog or wtmp -- rotate them here
153/var/log/wtmp {
154 monthly
155 create 0664 root utmp
156 rotate 1
157}
158
159/var/log/lastlog {
160 monthly
161 rotate 1
162}
163
164# Some packages drop log rotation info in this directory
165# so we include any file in it.
166include /etc/logrotate.d
167
168# End /etc/logrotate.conf</literal>
169EOF
170
171chmod -v 0644 /etc/logrotate.conf</userinput></screen>
172
173 <para>
174 Now create the <filename class='directory'>/etc/logrotate.d</filename>
175 directory as the <systemitem class="username">root</systemitem> user:
176 </para>
177
178<screen role="root"><userinput>mkdir -p /etc/logrotate.d</userinput></screen>
179
180 <para>
181 At this point additional log rotation commands can be entered, typically
182 in the <filename class='directory'>/etc/logrotate.d</filename> directory.
183 For example:
184 </para>
185
186<screen role="nodump"><userinput>cat &gt; /etc/logrotate.d/sys.log &lt;&lt; EOF
187<literal>/var/log/sys.log {
188 # If the log file is larger than 100kb, rotate it
189 size 100k
190 rotate 5
191 weekly
192 postrotate
193 /bin/killall -HUP syslogd
194 endscript
195}</literal>
196EOF
197
198chmod -v 0644 /etc/logrotate.d/sys.log</userinput></screen>
199
200 <para>
201 You can designate multiple files in one entry:
202 </para>
203
204<screen role="nodump"><userinput>cat &gt; /etc/logrotate.d/example.log &lt;&lt; EOF
205<literal>file1
206file2
207file3 {
208 ...
209 postrotate
210 ...
211 endscript
212}</literal>
213EOF
214
215chmod -v 0644 /etc/logrotate.d/example.log</userinput></screen>
216
217 <para>
218 You can use in the same line the list of files: file1 file2 file3.
219 See the logrotate man page or <ulink
220 url='http://www.techrepublic.com/article/manage-linux-log-files-with-logrotate/'/>
221 for more examples.
222 </para>
223
224 <para>
225 The command <command>logrotate /etc/logrotate.conf</command> can be
226 run manually, however, the command should be run daily.
227 Other useful commands are <command>logrotate -d
228 /etc/logrotate.conf</command> for debugging purposes and
229 <command>logrotate -f /etc/logrotate.conf</command> forcing the
230 logrotate commands to be run immediately. Combining the previous options
231 <option>-df</option>, you can debug the effect of the force command.
232 When debugging, the commands are only simulated and are not actually run.
233 As a result, errors about files not existing will eventually appear because
234 the files are not actually created.
235 </para>
236
237 <para>
238 To run the <command>logrotate</command> command daily,
239 <phrase revision="sysv">if you've installed
240 <xref linkend="fcron"/> and completed the section on periodic jobs,
241 execute</phrase><phrase revision="systemd">execute</phrase> the following
242 commands, as the <systemitem class="username">root</systemitem> user,
243 to create a <phrase revision="sysv">daily cron job:</phrase>
244 <phrase revision="systemd">systemd timer to run daily at 3:00 A.M.
245 (local time):</phrase>
246 </para>
247
248<screen role="root" revision="sysv"><userinput>cat &gt; /etc/cron.daily/logrotate.sh &lt;&lt; "EOF" &amp;&amp;
249<literal>#!/bin/bash
250/usr/sbin/logrotate /etc/logrotate.conf</literal>
251EOF
252chmod 754 /etc/cron.daily/logrotate.sh</userinput></screen>
253
254<screen role="root" revision="systemd"><userinput>cat &gt; /lib/systemd/system/logrotate.service &lt;&lt; "EOF" &amp;&amp;
255<literal>[Unit]
256Description=Runs the logrotate command
257Documentation=man:logrotate(8)
258DefaultDependencies=no
259After=local-fs.target
260Before=shutdown.target
261
262[Service]
263Type=oneshot
264RemainAfterExit=yes
265ExecStart=/usr/sbin/logrotate /etc/logrotate.conf</literal>
266EOF
267cat &gt; /lib/systemd/system/logrotate.timer &lt;&lt; "EOF" &amp;&amp;
268<literal>[Unit]
269Description=Runs the logrotate command daily at 3:00 AM
270
271[Timer]
272OnCalendar=*-*-* 3:00:00
273Persistent=true
274
275[Install]
276WantedBy=timers.target</literal>
277EOF
278systemctl enable logrotate.timer</userinput></screen>
279
280 </sect2>
281
282 <sect2 role="content">
283 <title>Contents</title>
284
285 <segmentedlist>
286 <segtitle>Installed Programs</segtitle>
287 <segtitle>Installed Library</segtitle>
288 <segtitle>Installed Directories</segtitle>
289
290 <seglistitem>
291 <seg> logrotate </seg>
292 <seg> None </seg>
293 <seg> None </seg>
294 </seglistitem>
295 </segmentedlist>
296
297 <variablelist>
298 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
299 <?dbfo list-presentation="list"?>
300 <?dbhtml list-presentation="table"?>
301
302 <varlistentry id="logrotate-prog">
303 <term><command>logrotate</command></term>
304 <listitem>
305 <para>
306 performs the log maintenance functions defined in the
307 configuration files
308 </para>
309 <indexterm zone="logrotate logrotate-prog">
310 <primary sortas="b-logrotate-prog">logrotate</primary>
311 </indexterm>
312 </listitem>
313 </varlistentry>
314
315 </variablelist>
316
317 </sect2>
318
319</sect1>
Note: See TracBrowser for help on using the repository browser.