Savelogs

The savelogs program rotates logs, optionally saving the old ones elsewhere and signalling the programs that created the logfiles.

Description

/etc/savelogs.conf tells savelogs which logs to rotate, when to rotate them, whether to back them up, and what to do after a log is rotated.
The format of the configuration file is a filename, followed by a list of commands, with punctuation and case ignored:

For example, the following configuration file

/var/adm/syslog EVERY WEEK
            SAVE 2 IN /var/adm/OLD
            TOUCH 644
            SIGNAL "killall -HUP syslogd"

Rotates /var/adm/syslog every sunday, creating a new empty file with mode 644, saving two of the old logs in /var/adm/OLD, and sending a HUP signal to syslogd after it’s finished.

Source Code

Version 1.5

Many many many feature changes

  1. Allow, globally and on a file by file basis, saving backups to numbered (NN.file) instead of dotted (ooo.file) names.
  2. Allow, globally and on a file by file basis, backup file compression.
  3. Set, globally and on a file by file basis, the format of the backup file from ooo.file to file.ooo.

In addition, the code has been ported to more systems, from recent versions of freebsd (macos, to be precise) to modern commercial linuxes.

Version 1.4
Discard the old handbuilt parser and switch over to using lex and yacc. I wanted to do some tweaking of the features for savelogs and decided that it was enough of a pain so that this was the time to discard my hand-built parser for a generated one.
Version 1.3
This version allows multiple SIGNALs per file, so I can do something like rotate many syslogs, hup syslogd, then hup a cwatch process if and only if /var/log/messages was one of those syslogs. I also made the code more portable by fitting it out with my autoconfiguration scripts. Savelogs now properly builds on pell, which is an SLS Linux system, egypt, which is my primary Mastodon build box, and downbelow, which runs an elderly version of FreeBSD.
Version 1.1
The first version under version control.