Next: , Previous: , Up: Services   [Contents][Index]


6.2.7.3 Log Rotation

Log files such as those found in /var/log tend to grow endlessly, so it’s a good idea to rotate them once in a while—i.e., archive their contents in separate files, possibly compressed. The (gnu services admin) module provides an interface to GNU Rot[t]log, a log rotation tool (see GNU Rot[t]log Manual).

The example below defines an operating system that provides log rotation with the default settings.

(use-modules (guix) (gnu))
(use-service-modules admin mcron)
(use-package-modules base idutils)

(operating-system
  ;; …
  (services (cons* (mcron-service)
                   (service rottlog-service-type)
                   %base-services)))
Scheme Variable: rottlog-service-type

This is the type of the Rottlog service, whose value is a rottlog-configuration object.

This service type can define mcron jobs (see Scheduled Job Execution) to run the rottlog service.

Data Type: rottlog-configuration

Data type representing the configuration of rottlog.

rottlog (default: rottlog)

The Rottlog package to use.

rc-file (default: (file-append rottlog "/etc/rc"))

The Rottlog configuration file to use (see Mandatory RC Variables in GNU Rot[t]log Manual).

periodic-rotations (default: `(("weekly" %default-rotations)))

A list of Rottlog period-name/period-config tuples.

For example, taking an example from the Rottlog manual (see Period Related File Examples in GNU Rot[t]log Manual), a valid tuple might be:

("daily" ,(plain-file "daily"
                      "\
     /var/log/apache/* {
        storedir apache-archives
        rotate 6
        notifempty
        nocompress
     }"))
jobs

This is a list of gexps where each gexp corresponds to an mcron job specification (see Scheduled Job Execution).

Scheme Variable: %default-rotations

Specifies weekly rotation of %rotated-files and "/var/log/shepherd.log".

Scheme Variable: %rotated-files

The list of syslog-controlled files to be rotated. By default it is: '("/var/log/messages" "/var/log/secure").


Next: , Previous: , Up: Services   [Contents][Index]