26 Mar 2007 20:17
Contribute: An attempt of hint
Hugo Adrián Segovia Cardozo <hugoa_c2004 <at> yahoo.com>
2007-03-26 18:17:30 GMT
2007-03-26 18:17:30 GMT
Hi!
I am Hugo S. Cardozo, and I use (B)LFS 6.2 for a while. I try some programs
with my system, and I want to contribute my experience with one of them.
Is about the installation of Logrotate 3.6.8
I am from Paraguay, so the English is not my native language. If you find
any typos or grammar mistakes in this hint, please let me know. And I am not
any typos or grammar mistakes in this hint, please let me know. And I am not
a guru neither. I made this hint because I want to give a little contribution to
the LFS community (¡Thanks for the many hours of frustration
and fun I spent making my own system!
. So, if you find any errors in the
commands or in the concepts, let me know too.
and fun I spent making my own system!
. So, if you find any errors in the commands or in the concepts, let me know too.
Last, I don´t know if I am suppose to send my hint to this mailing list, but I don´t
know other place to send it. If this isn´t the place, sorry, and let me know it.
Thanks!
Hugo S. Cardozo
AUTHOR: Hugo S. Cardozo <hugoa_c2004 <at> yahoo.com>
DATE: 2007-03-24
LICENSE: GNU Free Documentation License Version 1.2
SYNOPSIS: Logrotate: Keep your log files tidy
DESCRIPTION: This hint will help you to install and configure
logrotate for your (B)LFS system
logrotate for your (B)LFS system
ATTACHMENTS: * popt-1.6.3
ftp://slackware.cs.utah.edu/pub/slackware/slackware-10.1/source/l/popt/popt-1.7.tar.gz
ftp://slackware.cs.utah.edu/pub/slackware/slackware-10.1/source/l/popt/popt-1.7.tar.gz
* logrotate-3.6.8
ftp://slackware.mirrors.tds.net/pub/slackware/slackware-10.1/source/a/logrotate/logrotate-3.6.8.tar.gz
ftp://slackware.mirrors.tds.net/pub/slackware/slackware-10.1/source/a/logrotate/logrotate-3.6.8.tar.gz
PREREQUISITES: LFS installed and running.
Optionally, (F)cron.
Optionally, (F)cron.
HINT:
Introduction
============
============
Logrotate is an utility to take care of the log files of your system. It keeps
track of the size of the log files, and "rotates" them when needed. That minds,
the utility check the size of the files, an if one of them is larger than a
certain size, the program performs some actions. That actione can be: backup
and compress the file, remove it or mail it to an user, create a new empty
log file, and others.
track of the size of the log files, and "rotates" them when needed. That minds,
the utility check the size of the files, an if one of them is larger than a
certain size, the program performs some actions. That actione can be: backup
and compress the file, remove it or mail it to an user, create a new empty
log file, and others.
Installation
============
============
First, you need to compile and install popt-1.6.3. This is a library to
manage command-line arguments.
manage command-line arguments.
Unpack the tarball and cd into the popt sources:
tar xzf popt-1.6.3.tar.gz
cd popt-1.6.3
Compile and install:
./configure --prefix=/usr && \
make && make install
tar xzf popt-1.6.3.tar.gz
cd popt-1.6.3
Compile and install:
./configure --prefix=/usr && \
make && make install
Now you can compile logrotate. Unpack the tarball and cd:
tar xzf logrotate-3.6.8.tar.gz
cd logrotate-3.6.8
Compile:
make
Optionally, run the test suite:
make test
Install:
make install
tar xzf logrotate-3.6.8.tar.gz
cd logrotate-3.6.8
Compile:
make
Optionally, run the test suite:
make test
Install:
make install
Configuration
=============
=============
The command "logrotate" needs a config file, which must be passed as an
argument to the command when executed. We will put that file in "/etc",
and name it "logrotate.conf".
argument to the command when executed. We will put that file in "/etc",
and name it "logrotate.conf".
Create the file with this command:
cat >> /etc/logrotate.conf << EOF
# Begin of /etc/logrotate.conf
cat >> /etc/logrotate.conf << EOF
# Begin of /etc/logrotate.conf
# Rotate log files weekly
weekly
# No send mail to anybody
nomail
weekly
# No send mail to anybody
nomail
# If the log file is empty, it does not will be rotated
notifempty
notifempty
# Number of backups that will be kept
# This will keep the 2 newest backups only
rotate 2
# Create new empty files after rotate old ones
# This will create empty log files, with owner
# set to root, group set to sys, and permissions 644
create 0664 root sys
# This will keep the 2 newest backups only
rotate 2
# Create new empty files after rotate old ones
# This will create empty log files, with owner
# set to root, group set to sys, and permissions 644
create 0664 root sys
# Compress the backups with gzip
compress
compress
# RPM packages drop log rotation info in this directory,
# so we include any file in it.
include /etc/logrotate.d
# so we include any file in it.
include /etc/logrotate.d
# End of /etc/logrotate.conf
EOF
EOF
Also, you can use the file "logrotate-default", which is in the logrotate
sources, in the "examples" directory. I use some of the lines of that file
in my example above.
sources, in the "examples" directory. I use some of the lines of that file
in my example above.
When installing sysklogd, the LFS book defines some predefined log files
in
"/etc/syslog.conf". We can rotate those files by adding their definitions to
logrotate.conf. So, to add them, run this command:
for logfile in $(find /var/log/* -type f); do
echo "$logfile {" >> /etc/logrotate.conf
echo "# If the log file is larger" \
"than 100kb, rotate it" >> /etc/logrotate.conf"
echo " size=100k" >> /etc/logrotate.conf
echo "}" >> /etc/logrotate.conf
echo "" >> /etc/logrotate.conf
done
"/etc/syslog.conf". We can rotate those files by adding their definitions to
logrotate.conf. So, to add them, run this command:
for logfile in $(find /var/log/* -type f); do
echo "$logfile {" >> /etc/logrotate.conf
echo "# If the log file is larger" \
"than 100kb, rotate it" >> /etc/logrotate.conf"
echo " size=100k" >> /etc/logrotate.conf
echo "}" >> /etc/logrotate.conf
echo "" >> /etc/logrotate.conf
done
For details on configuring this file, see logrotate(8).
Logrotate as a Cron job
=======================
You can run logrotate just issuing "/usr/sbin/logrotate /etc/logrotate.conf"
but in this case, you should run that command by yourself, every day (or
week, or month...), if you want the program to work properly. This can be
very annoying
.
but in this case, you should run that command by yourself, every day (or
week, or month...), if you want the program to work properly. This can be
very annoying
.Instead, you can run it as a cron job. For the further configuration,
I will assume that you have installed Fcron from the BLFS book.
I will assume that you have installed Fcron from the BLFS book.
Create a /etc/fcrontab file by issuing this command:
cat >> /etc/fcrontab << EOF
0 12 * * * 0 /usr/sbin/logrotate /etc/logrotate.conf
EOF
This will make fcron execute logrotate once a week, in Sunday, at noon.
For details on configuring fcrontab, refer to fcrontab(1).
cat >> /etc/fcrontab << EOF
0 12 * * * 0 /usr/sbin/logrotate /etc/logrotate.conf
EOF
This will make fcron execute logrotate once a week, in Sunday, at noon.
For details on configuring fcrontab, refer to fcrontab(1).
You will need the "check_system_crontabs" from the fcron sources. If you
haven't installed it, do it by issuing:
tar xzf fcron-3.0.1.tar.gz
cp -v fcron-3.0.1/scripts/check_system_crontabs /usr/sbin
haven't installed it, do it by issuing:
tar xzf fcron-3.0.1.tar.gz
cp -v fcron-3.0.1/scripts/check_system_crontabs /usr/sbin
Then run the script:
check_system_crontabs -v
For help, type this:
check_system_crontabs -h
check_system_crontabs -v
For help, type this:
check_system_crontabs -h
VERSION: 1.00
CHANGELOG: 1.00 First
release
__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
Regístrate ya - http://correo.espanol.yahoo.com/
<div> <div>Hi!</div> <div> </div> <div>I am Hugo S. Cardozo, and I use (B)LFS 6.2 for a while. I try some programs</div> <div>with my system, and I want to contribute my experience with one of them. </div> <div>Is about the installation of Logrotate 3.6.8</div> <div> </div> <div>I am from Paraguay, so the English is not my native language. If you find<br>any typos or grammar mistakes in this hint, please let me know. And I am not</div> <div>a guru neither. I made this hint because I want to give a little contribution to </div> <div>the LFS community (¡Thanks for the many hours of frustration<br>and fun I spent making my own system!. So, if you find any errors in the <br>commands or in the concepts, let me know too.</div> <div> </div> <div>Last, I don´t know if I am suppose to send my hint to this mailing list, but I don´t</div> <div>know other place to send it. If this isn´t the place, sorry, and let me know it.</div> <div> </div> <div>Thanks!</div> <div> </div> <div>Hugo S. Cardozo</div> <div> </div> <div> </div> <div>AUTHOR: Hugo S. Cardozo <<a href="mailto:hugoa_c2004 <at> yahoo.com">hugoa_c2004 <at> yahoo.com</a>></div> <div>DATE: 2007-03-24</div> <div>LICENSE: GNU Free Documentation License Version 1.2</div> <div>SYNOPSIS: Logrotate: Keep your log files tidy</div> <div>DESCRIPTION: This hint will help you to install and configure<br> logrotate for your (B)LFS system</div> <div>ATTACHMENTS: * popt-1.6.3 <br> <a href="ftp://slackware.cs.utah.edu/pub/slackware/slackware-10.1/source/l/popt/popt-1.7.tar.gz">ftp://slackware.cs.utah.edu/pub/slackware/slackware-10.1/source/l/popt/popt-1.7.tar.gz</a> </div> <div> * logrotate-3.6.8 <br> <a href="ftp://slackware.mirrors.tds.net/pub/slackware/slackware-10.1/source/a/logrotate/logrotate-3.6.8.tar.gz">ftp://slackware.mirrors.tds.net/pub/slackware/slackware-10.1/source/a/logrotate/logrotate-3.6.8.tar.gz</a> </div> <div>PREREQUISITES: LFS installed and running.<br> Optionally, (F)cron.</div> <div>HINT:</div> <div>Introduction<br>============</div> <div>Logrotate is an utility to take care of the log files of your system. It keeps <br>track of the size of the log files, and "rotates" them when needed. That minds,<br>the utility check the size of the files, an if one of them is larger than a<br>certain size, the program performs some actions. That actione can be: backup <br>and compress the file, remove it or mail it to an user, create a new empty <br>log file, and others.</div> <div>Installation<br>============</div> <div>First, you need to compile and install popt-1.6.3. This is a library to<br>manage command-line arguments.</div> <div>Unpack the tarball and cd into the popt sources:<br> tar xzf popt-1.6.3.tar.gz<br> cd popt-1.6.3<br>Compile and install:<br> ./configure --prefix=/usr && \<br> make && make install</div> <div>Now you can compile logrotate. Unpack the tarball and cd:<br> tar xzf logrotate-3.6.8.tar.gz<br> cd logrotate-3.6.8<br>Compile:<br> make <br>Optionally, run the test suite:<br> make test<br>Install:<br> make install</div> <div>Configuration<br>=============</div> <div>The command "logrotate" needs a config file, which must be passed as an<br>argument to the command when executed. We will put that file in "/etc", <br>and name it "logrotate.conf".</div> <div>Create the file with this command:<br> cat >> /etc/logrotate.conf << EOF<br> # Begin of /etc/logrotate.conf</div> <div> # Rotate log files weekly<br> weekly<br> <br> # No send mail to anybody<br> nomail</div> <div> # If the log file is empty, it does not will be rotated<br> notifempty</div> <div> # Number of backups that will be kept<br> # This will keep the 2 newest backups only<br> rotate 2<br> <br> # Create new empty files after rotate old ones<br> # This will create empty log files, with owner<br> # set to root, group set to sys, and permissions 644<br> create 0664 root sys</div> <div> # Compress the backups with gzip<br> compress</div> <div> # RPM packages drop log rotation info in this directory,<br> # so we include any file in it.<br> include /etc/logrotate.d</div> <div> # End of /etc/logrotate.conf<br> EOF</div> <div>Also, you can use the file "logrotate-default", which is in the logrotate<br>sources, in the "examples" directory. I use some of the lines of that file<br>in my example above.</div> <div>When installing sysklogd, the LFS book defines some predefined log files in<br>"/etc/syslog.conf". We can rotate those files by adding their definitions to<br>logrotate.conf. So, to add them, run this command:<br> for logfile in $(find /var/log/* -type f); do<br> echo "$logfile {" >> /etc/logrotate.conf<br> echo "# If the log file is larger" \<br> "than 100kb, rotate it" >> /etc/logrotate.conf"<br> echo " size=100k" >> /etc/logrotate.conf<br> echo "}" >> /etc/logrotate.conf<br> echo "" >> /etc/logrotate.conf<br> done</div> <div>For details on configuring this file, see logrotate(8).</div> <div> <br>Logrotate as a Cron job<br>=======================</div> <div>You can run logrotate just issuing "/usr/sbin/logrotate /etc/logrotate.conf"<br>but in this case, you should run that command by yourself, every day (or<br>week, or month...), if you want the program to work properly. This can be <br>very annoying
.</div> <div>Instead, you can run it as a cron job. For the further configuration, <br>I will assume that you have installed Fcron from the BLFS book.</div> <div>Create a /etc/fcrontab file by issuing this command:<br> cat >> /etc/fcrontab << EOF<br> 0 12 * * * 0 /usr/sbin/logrotate /etc/logrotate.conf<br> EOF<br>This will make fcron execute logrotate once a week, in Sunday, at noon.<br>For details on configuring fcrontab, refer to fcrontab(1).</div> <div>You will need the "check_system_crontabs" from the fcron sources. If you<br>haven't installed it, do it by issuing:<br> tar xzf fcron-3.0.1.tar.gz<br> cp -v fcron-3.0.1/scripts/check_system_crontabs /usr/sbin</div> <div>Then run the script:<br> check_system_crontabs -v<br>For help, type this:<br> check_system_crontabs -h</div> <div> </div> <div> <br>VERSION: 1.00</div> <div>CHANGELOG: 1.00 First release<br> </div> <p> __________________________________________________<br>Correo Yahoo!<br>Espacio para todos tus mensajes, antivirus y antispam ¡gratis! <br>Regístrate ya - http://correo.espanol.yahoo.com/ </p> </div>
RSS Feed