Ubuntu Unleashed 2019 Edition: Covering 18.04, 18.10, 19.04

(singke) #1

need to understand it to configure logrotate to do what you want. You can
learn more about bash and shell scripting in Chapter 14, “Automating Tasks
and Shell Scripting.”


The important line right now is that last one, which lists the location of the
configuration file for logrotate. Here are the default contents of
/etc/logrotate.conf:


Click here to view code image


see "man logrotate" for details


#   rotate  log files   weeklyweekly
# use the syslog group by default, since this is the owning group# of
/var/log/syslog.su root syslog
# keep 4 weeks’ worth of backlogsrotate 4
# create new (empty) log files after rotating old onescreate

#   uncomment   this    if  you want    your    log files   compressed#compress
# packages drop log rotation information into this directoryinclude
/etc/logrotate.d
# no packages own wtmp, or btmp -- we'll rotate them
here/var/log/wtmp { missingok monthly create 0664 root utmp
rotate 1}
/var/log/btmp { missingok monthly create 0660 root utmp
rotate 1}
# system-specific logs may be configured here

This file includes useful comments, and what it can configure is
straightforward. If you can read the file, you probably already have a pretty
accurate guess as to what the various settings do. As the first comment in the
file says, the man page for logrotate has an explanation of everything that
you can consult if it is not already clear.


One interesting entry says that packages drop log rotation information into
/etc/logrotate.d. This is worth a closer look. The directory contains a
config file for applications that are installed using the package manager and
that log information. These files are named after the applications whose log
files they control. Let’s look at two examples. This first one is for apt, the
package manager:


Click here to view code image
/var/log/apt/term.log { rotate 12 monthly compress missingok
notifempty}
/var/log/apt/history.log { rotate 12 monthly compress missingok
notifempty}


There are two entries here, each for a different log file that is created and used
by apt. The entries define how many old versions of the log files to keep,

Free download pdf