lfs-uefi: fix efivar-37 FTBFS
[linux_from_scratch_hints.git] / logrorate.txt
bloba6976ad98321a0fc9e2cb371d7c7303bc895cde9
1 AUTHOR:         Hugo S. Cardozo <hugoa_c2004@yahoo.com>
3 DATE:           2007-03-31
5 LICENSE:        GNU Free Documentation License Version 1.2
7 SYNOPSIS:       Logrotate: Keep your log files tidy
9 DESCRIPTION:    This hint will help you to install and
10 configure
11                 logrotate for your (B)LFS system
13 ATTACHMENTS:    * logrotate-3.6.8
14                   <mirrordeslackware>/logrotate-3.6.8.tar.gz
16 PREREQUISITES:  LFS installed and running.
17                 Popt-1.10.4
18                 Optionally, (F)cron.
20 HINT:
22 Introduction
23 ============
25 Logrotate is an utility to take care of the log files of your system. It keeps
26 track of the size of the log files, and "rotates" them when needed. That means
27 the utility checks the size of the files, and if one of them is larger than a
28 certain size, the program performs some actions. That action can be: backup
29 and compress the file, remove it or mail it to an user, create a new empty
30 log file, and others.
32 Installation
33 ============
35 First, you need to compile and install popt-1.10.4. The BLFS book includes
36 the instructions for this. But, if for some (strange) reason you can`t get
37 the popt-1.10.4 tarball, you can use popt-1.6.3 either, or (maybe) any later
38 version.
40 Now you can compile logrotate. Unpack the tarball and
41 cd:
42         tar xzf logrotate-3.6.8.tar.gz
43         cd logrotate-3.6.8
44 Compile:
45         make 
46 Optionally, run the test suite:
47         make test
48 Install:
49         make install
51 Configuration
52 =============
54 The command "logrotate" needs a config file, which must be passed as an
55 argument to the command when executed. We will put that file in "/etc",
56 and name it "logrotate.conf".
58 Create the file with this command:
59         cat >> /etc/logrotate.conf << EOF
60         # Begin of /etc/logrotate.conf
62         # Rotate log files weekly
63         weekly
64         
65         # Don't send mail to anybody
66         nomail
68         # If the log file is empty, it will not be rotated
69         notifempty
71         # Number of backups that will be kept
72         # This will keep the 2 newest backups only
73         rotate 2
74         
75         # Create new empty files after rotate old ones
76         # This will create empty log files, with owner
77         # set to root, group set to sys, and permissions 644
78         create 0664 root sys
80         # Compress the backups with gzip
81         compress
83         # RPM packages drop log rotation info in this directory
84         # so we include any file in it.
85         include /etc/logrotate.d
87         # End of /etc/logrotate.conf
88         EOF
90 Also, you can use the file "logrotate-default", which is in the logrotate
91 sources, in the "examples" directory. I use some of the lines of that file
92 in my example above.
94 When installing sysklogd, the LFS book defines some predefined log files in
95 "/etc/syslog.conf". We can rotate those files by adding their definitions to
96 logrotate.conf. So, to add them, run this command:
97         for logfile in $(find /var/log/* -type f); do
98                 echo "$logfile {" >> /etc/logrotate.conf
99                 echo "# If the log file is larger" \
100                   "than 100kb, rotate it" >> /etc/logrotate.conf"
101                 echo "  size=100k" >> /etc/logrotate.conf
102                 echo "}" >> /etc/logrotate.conf
103                 echo "" >> /etc/logrotate.conf
104         done
106 For details on editing this file, see logrotate(8).
109 Logrotate as a Cron job
110 =======================
112 You can run logrotate just issuing "/usr/sbin/logrotate /etc/logrotate.conf"
113 but in this case, you should run that command by yourself, every day (or
114 week, or month...), if you want the program to work properly. This can be
115 very annoying :-).
117 Instead, you can run it as a cron job. For the further configuration,
118 I will assume that you have installed Fcron from the BLFS book.
120 Create a /etc/fcrontab file by issuing this command:
121         cat >> /etc/fcrontab << EOF
122         0 12 * * * 0    /usr/sbin/logrotate /etc/logrotate.conf
123         EOF
124 This will make fcron execute logrotate once a week, on Sunday, at noon.
125 For details on editing fcrontab, refer to fcrontab(1).
127 You will need the "check_system_crontabs" script from the fcron sources. If
128 you haven't installed it, do it by issuing:
129         tar xzf fcron-3.0.1.tar.gz
130         cp -v fcron-3.0.1/scripts/check_system_crontabs /usr/sbin
132 Then run the script:
133         check_system_crontabs -v
134 For help, type this:
135         check_system_crontabs -h
138 ACKNOWLEDGEMENTS:
139         * Alexander E. Patrakov, for pointing me for the BLFS
140 version of
141           popt (Before I used the popt included in Slackware 10.1)
144 VERSION:        1.1
146 CHANGELOG:      1.00 First release
147                 1.1 Corrected popt section, fixed typos.