| 2 | | DATE: 2007-03-24 |
|---|
| 3 | | LICENSE: GNU Free Documentation License Version 1.2 |
|---|
| 4 | | SYNOPSIS: Logrotate: Keep your log files tidy |
|---|
| 5 | | DESCRIPTION: This hint will help you to install and configure |
|---|
| 6 | | logrotate for your (B)LFS system |
|---|
| 7 | | ATTACHMENTS: * popt-1.6.3 |
|---|
| 8 | | ftp://slackware.cs.utah.edu/pub/slackware/slackware-10.1/source/l/popt/popt-1.7.tar.gz |
|---|
| 9 | | * logrotate-3.6.8 |
|---|
| 10 | | ftp://slackware.mirrors.tds.net/pub/slackware/slackware-10.1/source/a/logrotate/logrotate-3.6.8.tar.gz |
|---|
| | 2 | |
|---|
| | 3 | DATE: 2007-03-31 |
|---|
| | 4 | |
|---|
| | 5 | LICENSE: GNU Free Documentation License Version 1.2 |
|---|
| | 6 | |
|---|
| | 7 | SYNOPSIS: Logrotate: Keep your log files tidy |
|---|
| | 8 | |
|---|
| | 9 | DESCRIPTION: This hint will help you to install and |
|---|
| | 10 | configure |
|---|
| | 11 | logrotate for your (B)LFS system |
|---|
| | 12 | |
|---|
| | 13 | ATTACHMENTS: * logrotate-3.6.8 |
|---|
| | 14 | <mirrordeslackware>/logrotate-3.6.8.tar.gz |
|---|
| | 15 | |
|---|
| 17 | | track of the size of the log files, and "rotates" them when needed. That minds, |
|---|
| 18 | | the utility check the size of the files, an if one of them is larger than a |
|---|
| 19 | | certain size, the program performs some actions. That actione can be: backup |
|---|
| | 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 |
|---|
| 24 | | First, you need to compile and install popt-1.6.3. This is a library to |
|---|
| 25 | | manage command-line arguments. |
|---|
| 26 | | Unpack the tarball and cd into the popt sources: |
|---|
| 27 | | tar xzf popt-1.6.3.tar.gz |
|---|
| 28 | | cd popt-1.6.3 |
|---|
| 29 | | Compile and install: |
|---|
| 30 | | ./configure --prefix=/usr && \ |
|---|
| 31 | | make && make install |
|---|
| 32 | | Now you can compile logrotate. Unpack the tarball and cd: |
|---|
| 33 | | tar xzf logrotate-3.6.8.tar.gz |
|---|
| 34 | | cd logrotate-3.6.8 |
|---|
| | 34 | |
|---|
| | 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. |
|---|
| | 39 | |
|---|
| | 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 |
|---|
| 47 | | cat >> /etc/logrotate.conf << EOF |
|---|
| 48 | | # Begin of /etc/logrotate.conf |
|---|
| 49 | | # Rotate log files weekly |
|---|
| 50 | | weekly |
|---|
| 51 | | |
|---|
| 52 | | # No send mail to anybody |
|---|
| 53 | | nomail |
|---|
| 54 | | # If the log file is empty, it does not will be rotated |
|---|
| 55 | | notifempty |
|---|
| 56 | | # Number of backups that will be kept |
|---|
| 57 | | # This will keep the 2 newest backups only |
|---|
| 58 | | rotate 2 |
|---|
| 59 | | |
|---|
| 60 | | # Create new empty files after rotate old ones |
|---|
| 61 | | # This will create empty log files, with owner |
|---|
| 62 | | # set to root, group set to sys, and permissions 644 |
|---|
| 63 | | create 0664 root sys |
|---|
| 64 | | # Compress the backups with gzip |
|---|
| 65 | | compress |
|---|
| 66 | | # RPM packages drop log rotation info in this directory, |
|---|
| 67 | | # so we include any file in it. |
|---|
| 68 | | include /etc/logrotate.d |
|---|
| 69 | | # End of /etc/logrotate.conf |
|---|
| 70 | | EOF |
|---|
| | 59 | cat >> /etc/logrotate.conf << EOF |
|---|
| | 60 | # Begin of /etc/logrotate.conf |
|---|
| | 61 | |
|---|
| | 62 | # Rotate log files weekly |
|---|
| | 63 | weekly |
|---|
| | 64 | |
|---|
| | 65 | # Don't send mail to anybody |
|---|
| | 66 | nomail |
|---|
| | 67 | |
|---|
| | 68 | # If the log file is empty, it will not be rotated |
|---|
| | 69 | notifempty |
|---|
| | 70 | |
|---|
| | 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 |
|---|
| | 79 | |
|---|
| | 80 | # Compress the backups with gzip |
|---|
| | 81 | compress |
|---|
| | 82 | |
|---|
| | 83 | # RPM packages drop log rotation info in this directory |
|---|
| | 84 | # so we include any file in it. |
|---|
| | 85 | include /etc/logrotate.d |
|---|
| | 86 | |
|---|
| | 87 | # End of /etc/logrotate.conf |
|---|
| | 88 | EOF |
|---|
| | 89 | |
|---|
| 77 | | for logfile in $(find /var/log/* -type f); do |
|---|
| 78 | | echo "$logfile {" >> /etc/logrotate.conf |
|---|
| 79 | | echo "# If the log file is larger" \ |
|---|
| 80 | | "than 100kb, rotate it" >> /etc/logrotate.conf" |
|---|
| 81 | | echo " size=100k" >> /etc/logrotate.conf |
|---|
| 82 | | echo "}" >> /etc/logrotate.conf |
|---|
| 83 | | echo "" >> /etc/logrotate.conf |
|---|
| 84 | | done |
|---|
| 85 | | For details on configuring this file, see logrotate(8). |
|---|
| | 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 |
|---|
| | 105 | |
|---|
| | 106 | For details on editing this file, see logrotate(8). |
|---|
| | 107 | |
|---|
| 96 | | cat >> /etc/fcrontab << EOF |
|---|
| 97 | | 0 12 * * * 0 /usr/sbin/logrotate /etc/logrotate.conf |
|---|
| 98 | | EOF |
|---|
| 99 | | This will make fcron execute logrotate once a week, in Sunday, at noon. |
|---|
| 100 | | For details on configuring fcrontab, refer to fcrontab(1). |
|---|
| 101 | | You will need the "check_system_crontabs" from the fcron sources. If you |
|---|
| 102 | | haven't installed it, do it by issuing: |
|---|
| 103 | | tar xzf fcron-3.0.1.tar.gz |
|---|
| 104 | | cp -v fcron-3.0.1/scripts/check_system_crontabs /usr/sbin |
|---|
| | 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). |
|---|
| | 126 | |
|---|
| | 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 |
|---|
| | 131 | |
|---|