truncate_log - eliminate old lines in a log file.
truncate_log [-cfrv] [-d ndays] [-h max-history] [-m max] [-s min] log
[log..]
Logs from the real time system may grow without bound unless
trimmed occasionally. This script trims logs by inspecting the
time tags which are by default placed on every log line (from
the elog(3) routines).
In addition, it trims the rtsys database, which contains a few tables
which can otherwise grow with every execution. These files are less of
an issue, but might still cause problems on long-running systems, especially
where certain cron jobs run multiple times per day.
truncate_log is most safely run when the system
is down, but may be run on a live system. However, this
should be done cautiously as truncate_log pauses and continues
each process associated with a log file in an attempt to avoid
losing output.
truncate_log also removes the old log directories
(created by restarting rtexec) and old core files
if they are older than the specified
threshold.
-
-c
also remove lines without time tags.
-
-d n
Trim lines before n days ago. The default is 14 days;
the minimum is 8 days, unless the -f option is specified.
-
-f
truncate files sooner than eight days earlier. This may
impede debugging efforts; if some logs are too large after 8 days,
chances are that the verbosity is turned too high for those
processes.
-
-h max-history
Override the default of 20 * ndays for the maximum number of
records to leave in the history, cron_history and shutdown tables
of the rtsys/rtsys database.
Specifying max_history of zero turns off the trimming of the
rtsys tables altogether.
-
-r
unless the -r option is specified, the lines removed are left
in a new file with an additional dash suffix (e.g., "log" becomes "log-").
-
-v
be more verbose
-
-s min
Only trim files larger than min kbytes;
the default is 50 kbytes. Smaller log files
are preserved in their entirety, which is more useful
when tracking down a problem.
-
-m max
Trim log files to a maximum of max kbytes.
% truncate_log -d 7 -r -v logs/*
rtexec(1)
elog(3)
-
rtm normally starts rtexec with
the -s option, causing old logs to be saved into a subdirectory.
This may be adequate for many purposes.
-
truncate_log uses temporary files with suffixes "-" and "+"; other files
with the same names could be replaced or removed.
-
truncate_log uses STOP and CONT signals to stop and continue processes
associated with a log file. If the process were
stopped for too long, this might cause problems.
-
The errors file may be written to by all the real time processes, but truncate_log
ignores this problem. Potentially, some lines might be written into the
errors file during the process of truncation.
-
If no lines matching the specified day are found, the file is not
truncated, unless the file is
larger than the maximum specified with the -m option.
-
The -c option works only when a line matching the specified day is
found.
-
When -c and -m are used together, the resulting file may be considerably
smaller than the specified maximum.
Daniel M. Quinlan, danq@brtt.com
Table of Contents
Antelope Release 4.9 Linux SuSE 9.3 (i586) 2.6.11.4 2007-10-19
Boulder Real Time Technologies, Inc
For more information, contact support@brtt.com