Next: , Previous: , Up: Services   [Contents][Index] 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, for commonly encountered log files.

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

  ;; …
  (services (cons* (service mcron-service-type)
                   (service rottlog-service-type)
Scheme Variable: rottlog-service-type

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

Other services can extend this one with new log-rotation objects (see below), thereby augmenting the set of files to be rotated.

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).

rotations (default: %default-rotations)

A list of log-rotation objects as defined below.


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

Data Type: log-rotation

Data type representing the rotation of a group of log files.

Taking an example from the Rottlog manual (see Period Related File Examples in GNU Rot[t]log Manual), a log rotation might be defined like this:

  (frequency 'daily)
  (files '("/var/log/apache/*"))
  (options '("storedir apache-archives"
             "rotate 6"

The list of fields is as follows:

frequency (default: 'weekly)

The log rotation frequency, a symbol.


The list of files or file glob patterns to rotate.

options (default: '())

The list of rottlog options for this rotation (see Configuration parameters in GNU Rot[t]lg Manual).

post-rotate (default: #f)

Either #f or a gexp to execute once the rotation has completed.

Scheme Variable: %default-rotations

Specifies weekly rotation of %rotated-files and a couple of other files.

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]