SMARTLOG(1) SMARTLOG(1)
User commands User commands
November 18, 1997
NAME
smartlog - logfile maintenance utility
SYNOPSIS
smartlog [-a] [-d directory] [-n] [-q] [-v]
DESCRIPTION
smartlog was written to prevent logfiles from growing out of bounds.
It will manage archives with sliding histories of log messages. It
collects the logfiles spread all over the system in one directory and
gives you various possibilities to process these archives.
smartlog reads its rc file and writes messages to its logfile. By
default, the rc file has the name $HOME/.smartlog/smartlogrc and the
logfile has the name $HOME/.smartlog/logfile. If $HOME/.smartlog does
not exist it will be created automagically unless you have chosen an
alternative directory using option -d (--dir).
The rc file consists of lines which have one of the following forms:
var=value assign value to var
var= reset var to its default value
var=def same
var=default same
logfile=value{:var=value} see below
# comment
Blank lines are allowed to increase readability. You must not use any
quote characters, spaces or tab stops within assignments, except for
the date, bsh, ash and nsh fields (no singlequotes allowed at all).
If an invalid line was detected smartlog will stop any further actions
to protect following archives, you may turn this off using option -a
(--always).
The global defaults may be changed in smartlog.def.
The value of a variable (e.g. arch) will be referred to as variable-
value (arch-value).
arch, archive
defines an alternate archive file name instead of the default.
No .SLA suffix will be appended to this name. The notation
arch=*whatever will append whatever to the current value of arch.
To unset this field you can assign an empty string or the literal
none. The default is to use dir-
value/complete.path.to.logfile.thelogfile.SLA.
ash ash-value is a bourne shell command which will be executed after
any action or the literal none for no command. You may use pipes
here.
- 1 - Formatted: December 14, 2025
SMARTLOG(1) SMARTLOG(1)
User commands User commands
November 18, 1997
bsh Similar to ash, but the command, if any, will be executed before
any action.
comp, compress
This can be set to any word starting with y or n (case
insensitive). Simple occurance of the keyword means yes. If
set, the archive will be compressed. When used with shift an
integer value is interpreted as the first archive to be
compressed, otherwise (if set to yes) all archives will be
compressed. You can turn this on or off as you like, archives are
handled pertinently.
date this defines another value for date, default is @date@
DEFAULTS
make the current settings the defaults. Use with care, because
incorrect default values will make efficient working very hard!
dir dir-value specifies the archive directory. During the
installation the default was set to @dir@. All archives will go
here unless you set local.
ext selects a new extension which is appended to compressed archives.
If set to auto it will be set according to the given compress
binary: ext-value is .Z for compress(1), .gz for gzip(1), .z for
zip(1), .C for compact(1), .F for freeze(1) or .SLAZ if none of
those can be matched.
Using auto is very useful if you want to work with different
compression programs. If you use only one, it is recommended to
set ext for performance reasons.
Compressing and uncompressing works independently of the chosen
extension.
Warning: Some compression programs insist on a certain extension
and will refuse to uncompress files with a different extension.
hold is the number of generations you want to hold in the archive. If
used with shift, hold will be the maximum number of archives to
be created.
logfile
is the file you want to archive e.g. /var/smail/log/logfile
(wildcards allowed). You should use absolute pathnames,
otherwise you may run into trouble. Unlike other variable
assignments, logfile allows further assignments on the same line,
seperated by colons. The scope of these assignments is limited
to this line only and does not change their global values.
If you use wildcards note that every match will get its own
archive unless you set arch which will join all matching logfiles
in one archive. Be sure hold is not defined too small, you may
- 2 - Formatted: December 14, 2025
SMARTLOG(1) SMARTLOG(1)
User commands User commands
November 18, 1997
loose archive information then.
local
place the archive file in the directory of the logfile and do not
create it in dir-value. This can be set to any word starting
with y or n (case insensitive). Simple occurance of the keyword
means yes.
mode usually the logfiles' modes and ownerships will be used for
archives. mode allows you to use alternative settings. The
format is mode=[uid].[gid]/[modemask] where [uid].[gid]/ or
/[modemask] may be omitted. * maybe used at any of the three
positions to use the corresponding value of the logfile. Default
is to use mode=*.*/*.
nsh The value of nsh is a bourne shell command which will be executed
if no action is performed. This happens when the logfile has a
size below size-value bytes. Again, the literal none can be used
to execute no command.
shift
This can be set to any word starting with y or n (case
insensitive). Simple occurance of the keyword means yes. If
set, every time smartlog runs on the logfile, the archives will
be shifted one position (archive.1->archive.2 ...
archive.n->archive.n+1) and the logfile becomes archive.1. There
will be no .SLA suffix in shifting mode. If not set, there will
be only one archive with a delimiter seperating the generations
inside the file.
size only logfiles greater or equal size-value bytes will be archived.
tmp selects an alternate directory for temporary files. During
installation the default was set to @tmp@.
zap zap-value is the name of an uncompression program (should
correspond to zip-value).
zip specifies the name of a compression program.
OPTIONS
-a, --always
continue processing the rc-files even if an invalid line was
detected. (debugging option, not recommended)
-d, --dir
use alternate directory instead of $HOME/.smartlog.
-n, --noexec
- 3 - Formatted: December 14, 2025
SMARTLOG(1) SMARTLOG(1)
User commands User commands
November 18, 1997
do not execute but show the work (debugging option).
-q, --quiet
work silently, only warnings and errors are reported to the
logfile.
-v, --verbose
makes smartlog work very noisy. Parsing and working are well
documented.
EXAMPLES
var=value
# all assignments are local in the next line
logfile=/doug/adams/hgttg:var=value:var=:var=
# the next lines reset var to the default (flexible syntax)
var=
var=def
var=default
For a detailed description have a look at
@installdir@/rc.(sample|bytewurm).
ENVIRONMENT
smartlog requires the environment variable HOME to be set properly.
Make sure it is if you use cron(8).
FILES
@installdir@/smartlog
main program
@installdir@/smartlog.awk
rc-file parser
@installdir@/smartlog.sh
does the real work
@installdir@/smartlog.def
the initial settings for smartlog
@installdir@/rc.sample
some examples
@installdir@/rc.bytewurm
the smartlogrc for my own system
$HOME/.smartlog/smartlogrc
users' personal rc-file
$HOME/.smartlog/logfile
users' logfile of smartlog-activity
- 4 - Formatted: December 14, 2025
SMARTLOG(1) SMARTLOG(1)
User commands User commands
November 18, 1997
$HOME/.smartlog/files
list of archives created during the last run. This file contains
all necessary informations for showlog(1) and should not be
deleted or modified.
NOTES
Archives are converted if you switch between standard and shifting
mode. Overhanging shift-archives and generations will be deleted
(depending on hold). This will NOT work if you changed local or arch,
too. Converting will fail on a changed ext-value as well. On ANY
converting the date-informations will be lost.
You have to uncompress all your archives if you change any of the zip,
zap or ext-fields. If you don't, smartlog will definitely produce
corrupt archives.
If a variable is set more than once in a logfile-line the last value
will be used.
If you use hold=value within a logfile-line you may simply write
something like logfile=/do/not/panic:14
There will be no operation on logfile and archives if the logfile is
no regular file or has a size lower than size-value bytes; if set nsh
will be executed then.
After archiving it the logfile will be cleared (well, the whole stuff
wouldn't make any sense if not :-).
Using absolute pathes in smartlogrc (for logfile, zip, zap, dir, tmp
and date) is highly recommended.
There is no way to quote hashes (#), they always introduce comments.
WARNINGS
You must not use identical archivenames in the same directory! (The
archivename does NOT include suffices or shiftlog-extensions!)
Disobeying will result in panic-exits or corrupt archives. Take
extreme care if you set arch, make sure it will not be active for the
wrong group of logfiles.
Detection of invalid lines causes smartlog to stop all actions to
protect following archives from being corrupted. It is highly
recommended not to deactivate this (-a).
DIAGNOSTICS
smartlog has very detailed error messages. Initial errors such as
missing files etc. will be printed to stderr and smartlog exits back
to the shell with status 1 for program failure or status 64 for usage
- 5 - Formatted: December 14, 2025
SMARTLOG(1) SMARTLOG(1)
User commands User commands
November 18, 1997
failure. Errors occuring during work will be reported in the logfile
($HOME/.smartlog/logfile). Since error messages are self explaining I
will list only the worst one with some suggestions to fix the trouble.
double archive file1 & file2
archives with the same basename exist in the same place, remove
one of them or use different directories. An intelligent arch
setting may help you up as well. Warning: The checks for non
unique archive file names may not catch all cases.
AUTHORS
smartlog (c) 1994-1997 by Michael 'Bytewurm' Weber
(Michael.Weber@rising-systems.de) (idea, realisation and main
coordination), Wolfgang Stumvoll (awk parser, getmode, general advice)
and Stephen R. van den Berg (shiftlog routines, general advice). Send
any reports, suggstions etc. to Michael 'Bytewurm' Weber
(Michael.Weber@rising-systems.de).
SEE ALSO
showlog(1), syslogd(8)
- 6 - Formatted: December 14, 2025